Fixed DropByIndex function for the case when a negative index exceeds
the slice size. This caused subsequent indices to have incorrect
offsets, leading to incorrect results.
Example of the bug:
DropByIndex([]int{0, 1, 2, 3, 4}, -100, 4)
returned []int{0, 1, 2, 4} instead of []int{0, 1, 2, 3}
Improvements:
- Removed map-based uniqueness check, now uses sorted iteration with O(1) memory
- Added copy of indexes to prevent mutation of input
- Fixed negative index handling logic
- Improved range check using uint for proper bounds validation
Performance:
- Time: -75.61% (geomean)
- Memory: -62.65% (geomean)
- Allocations: -43.67% (geomean)
Additional:
- Optimized Filter and FilterI in mutable/slice.go
* Fix linting
* Use is.ElementsMatch
This will ignore the ordering of the final intersection. Especially
important when checking old versions of go that do not guarantee an order
when iterating through maps.
* lint: fix inconsistent callback function parameter names
* lint: rename "iteratee" to "transform" for *Map helpers
* lint: rename "project" parameters to "transform"
* lint: rename "cb" parameters to "callback"
* lint: rename "iteratee" to "callback" for ForEach helpers
---------
Co-authored-by: Franky W. <frankywahl@users.noreply.github.com>
Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
* lint: pin golangci-lint version
* lint: use is.Empty where possible
* lint: use is.ElementsMatch for unsorted slices
* lint: remove redundant is.Len assertions
* lint: use is.Zero to assert zero structs
* fix: misc assertion issues
* lint: more consistent test case pattern
* fix: reversed expect/actual assert values
* lint: use is.ErrorIs and is.EqualError for errors
* Update golangci-lint version in workflow
---------
Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>