Repository navigation
fix Array#delete always firing the block when deleting nil - #6235
Merged
Merged
Conversation
reimplement `Array#delete` in c, fixing `ary.delete(nil, &blk)` firing the block regardless of removal
minimal reproduction:
```rb
ary = [nil]
ret = ary.delete(nil) { "not deleted?" }
```
phi-luna
marked this pull request as draft
April 12, 2024 15:36
phi-luna
marked this pull request as ready for review
April 12, 2024 15:51
Member
|
Thanks for the PR. But as a principle, the mruby standard library does not call blocks from C code unless absolutely necessary (to avoid VM recursion). I do not consider it an absolute necessity this time.
Which is your preference? |
Contributor
Author
|
thank you for the comment. i will amend the pr. |
Member
|
I that case, you can implement the body part in C (which probably returns index or - 1; you may name it __delete), or you can fix the Ruby code. |
Contributor
Author
|
i will check whether implementing the core part in c is worthwhile and will come back with results edit: |
Contributor
Author
|
this pr is ready to merge |
Member
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
reimplement
Array#deletein c, fixingary.delete(nil, &blk)firing the block regardless of removalminimal reproduction:
result on
master:result after this patch: