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 replace()/replace!() for ChainedVector when supplying count #113

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

laborg
Copy link
Contributor

@laborg laborg commented Dec 21, 2024

Fix #112

Not sure if this is the fastest implementation, but now it does what I would have expected from it and is in line with the behaviour of replace/replace! on an ordinary Array

Copy link
Member

@ararslan ararslan left a comment

Choose a reason for hiding this comment

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

Implementation looks good I think, but it'd be nice to have tests for replace (currently they're only for replace!), for the error thrown when count < 0, and for the behavior when count == 0.

if R[ri] == old && reps < count
R[ri] = new
reps += 1
continue
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
continue

The continue has no effect here; there's nothing else in the loop body that appears after it so the loop will continue regardless.

if A[i] == old
A[i] = new
reps += 1
continue
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
continue

(Same comment as in the other function)

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.

replace[!]() with count is broken
2 participants