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

Fix Regex::replacen when replacing an empty match. #395

Merged
merged 1 commit into from
Nov 9, 2017

Conversation

Lapin0t
Copy link
Contributor

@Lapin0t Lapin0t commented Aug 20, 2017

Fixes #393, #394.

There was some logic error when deciding to return Cow::Borrowed vs Cow::Owned in the fast-path. I took the same solution as the slow-path, ie use peekable on the iterator. I'm not sure this is the most efficient way (maybe just add mut did_replace = false and set it to true in the loop), but it does the job.

@Lapin0t
Copy link
Contributor Author

Lapin0t commented Aug 20, 2017

Note that i don't know why the CI checks are failing, something seemingly unrelated to this part of the code.

@Lapin0t
Copy link
Contributor Author

Lapin0t commented Oct 15, 2017

Bump 🐅... Not sure if I should do anything or not right now! I guess someone would have to review this (actually this is really just a couple line, still I'm not sure about the simplicity of the code but now it's consistent). Note: I rebased on master to enable fast-forward.

@mbrubeck
Copy link
Contributor

mbrubeck commented Nov 9, 2017

I just ran into this bug. This fix looks correct to me. @BurntSushi, r?

@BurntSushi
Copy link
Member

Right, sorry, forgot about this. LGTM. Thanks so much for the bug fix! @bors r+

@bors
Copy link
Contributor

bors commented Nov 9, 2017

📌 Commit 408add0 has been approved by BurntSushi

@bors
Copy link
Contributor

bors commented Nov 9, 2017

⌛ Testing commit 408add0 with merge 37bfbd9...

bors added a commit that referenced this pull request Nov 9, 2017
Fix `Regex::replacen` when replacing an empty match.

Fixes #393, #394.

There was some logic error when deciding to return `Cow::Borrowed` vs `Cow::Owned` in the fast-path. I took the same solution as the slow-path, ie use `peekable` on the iterator. I'm not sure this is the most efficient way (maybe just add `mut did_replace = false` and set it to true in the loop), but it does the job.
@bors
Copy link
Contributor

bors commented Nov 9, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: BurntSushi
Pushing 37bfbd9 to master...

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.

None yet

4 participants