Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up replacen loop #930

Merged
merged 2 commits into from
Nov 28, 2022
Merged

Conversation

xkr47
Copy link
Contributor

@xkr47 xkr47 commented Nov 28, 2022

replacen() (and therefore also replace()) was postponing checking against the limit until next iteration, which causes it to unnecessarily execute a "find" one extra time after the limit has been reached.

Also added two unit tests for replacen() since there were none.

@xkr47 xkr47 force-pushed the speed-up-replacen-loop branch from 07104e2 to a8358e6 Compare November 28, 2022 12:01
Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find!

@BurntSushi BurntSushi merged commit ac2d0e1 into rust-lang:master Nov 28, 2022
crapStone added a commit to Calciumdibromid/CaBr2 that referenced this pull request Jan 10, 2023
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [regex](https://github.com/rust-lang/regex) | dependencies | patch | `1.7.0` -> `1.7.1` |

---

### Release Notes

<details>
<summary>rust-lang/regex</summary>

### [`v1.7.1`](https://github.com/rust-lang/regex/blob/HEAD/CHANGELOG.md#&#8203;171-2023-01-09)

[Compare Source](rust-lang/regex@1.7.0...1.7.1)

\==================
This release was done principally to try and fix the doc.rs rendering for the
regex crate.

Performance improvements:

-   [PERF #&#8203;930](rust-lang/regex#930):
    Optimize `replacen`. This also applies to `replace`, but not `replace_all`.

Bug fixes:

-   [BUG #&#8203;945](rust-lang/regex#945):
    Maybe fix rustdoc rendering by just bumping a new release?

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC45NC4wIiwidXBkYXRlZEluVmVyIjoiMzQuOTQuMCJ9-->

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Co-authored-by: crapStone <crapstone01@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1711
Reviewed-by: crapStone <crapstone@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants