Skip to content

feat: add removeValues function to array utilities#399

Merged
LordMidas merged 2 commits into
developmentfrom
feat-array-removeValues-function
Aug 5, 2024
Merged

feat: add removeValues function to array utilities#399
LordMidas merged 2 commits into
developmentfrom
feat-array-removeValues-function

Conversation

@LordMidas

@LordMidas LordMidas commented Jul 20, 2024

Copy link
Copy Markdown
Member

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.

@LordMidas LordMidas requested review from Enduriel and TaroEld July 20, 2024 05:27
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.
@LordMidas LordMidas force-pushed the feat-array-removeValues-function branch from 04d1fcc to e2c2ec9 Compare July 20, 2024 05:28
Comment thread msu/utils/array.nut
@LordMidas LordMidas requested a review from TaroEld August 3, 2024 22:23
@TaroEld

TaroEld commented Aug 4, 2024

Copy link
Copy Markdown
Member

Pretty sure endy meant returning the removed values as an array would be non standard.

@LordMidas LordMidas merged commit 3fbf5ec into development Aug 5, 2024
@LordMidas LordMidas deleted the feat-array-removeValues-function branch August 5, 2024 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants