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 2 commits into from Nov 28, 2022


Copy link

@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.

Copy link

@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
10 checks passed
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]( | dependencies | patch | `1.7.0` -> `1.7.1` |


### Release Notes


### [`v1.7.1`](;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 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?



### 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](

Co-authored-by: cabr2-bot <>
Co-authored-by: crapStone <>
Reviewed-by: crapStone <>
Co-authored-by: Calciumdibromid Bot <>
Co-committed-by: Calciumdibromid Bot <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants