feat: add removeValues function to array utilities#399
Merged
Conversation
This function removes given values from an array in place as opposed to the native filter function that returns a new array. Doing `_values.find` is expected to be faster than first converting `_values` to a local table and then using `in` for each element in `_array`. This is because looking up values that don't exist in a table is a slower operation than using `find` on an array especially at smaller len - which `_values` is expected to have.
04d1fcc to
e2c2ec9
Compare
TaroEld
requested changes
Aug 3, 2024
Enduriel
approved these changes
Aug 3, 2024
Member
|
Pretty sure endy meant returning the removed values as an array would be non standard. |
TaroEld
approved these changes
Aug 4, 2024
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.
This function removes given values from an array in place as opposed to the native filter function that returns a new array. Doing
_values.findis expected to be faster than first converting_valuesto a local table and then usinginfor each element in_array. This is because looking up values that don't exist in a table is a slower operation than usingfindon an array especially at smaller len - which_valuesis expected to have.