871 Commits

Author SHA1 Message Date
Samuel Berthe dd1d58e324 feat: adding FindDuplicatesByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 693e1ce3a8 feat: adding FilterMapToSliceErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 7c55e5b6e3 feat: adding CrossJoinByErrX helpers 2026-03-02 16:06:51 +01:00
Samuel Berthe 8295993219 feat: adding FindErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe e94aa8d408 feat: adding ZipByErrX helpers 2026-03-02 16:06:51 +01:00
Samuel Berthe 64b0378b52 fix: fix inconsistent behavior on early return (return zero value instead of partial result) 2026-03-02 16:06:51 +01:00
Samuel Berthe fcc4f11fb5 💄 2026-03-02 16:06:51 +01:00
Samuel Berthe 5163ac211e fix: fix flaky test 2026-03-02 16:06:51 +01:00
Samuel Berthe cd78292882 💄 2026-03-02 16:06:51 +01:00
Samuel Berthe f0d6424eb0 feat: adding lots of examples of the new helpers 2026-03-02 16:06:51 +01:00
Samuel Berthe 18d953abf2 feat: adding lots of examples of the new helpers 2026-03-02 16:06:51 +01:00
Samuel Berthe 4584a0b848 feat: adding LatestByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 2e0b3a19c9 feat: adding EarliestByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 32dce47128 feat: adding MinIndexByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe bef45080d4 feat: adding MaxIndexByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 1db8f69a48 feat: adding KeyByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe fadc3aa9d5 feat: adding MaxByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 1342d124d5 feat: adding PartitionByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 1da649cc26 feat: adding WithoutByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 0950850fe2 feat: adding GroupByMapErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe c9783b717b feat: adding MinByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 75474ff444 feat: adding GroupByErr+CountByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 153f867680 feat: adding MeanByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe b0b34ffc94 feat: adding UniqByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 788fb2997c feat: adding OmitByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe e9037c6e8c feat: adding ProductByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 2fac7c49dd feat: adding PickByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 361866b4d4 feat: adding ReduceRightErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 993b074a87 feat: adding MapToSliceErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 20d76196f2 feat: adding ReduceErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 12e2b4ceb4 feat: adding SumByErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe f69cbe70f1 feat: adding MapEntiesErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 75d813d292 feat: adding FlatMapErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe ec67399cd4 feat: adding MapErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe b1263d4a41 feat: adding MapValuesErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe d4146ceb18 feat: adding MapKeysErr helper 2026-03-02 16:06:51 +01:00
Samuel Berthe 14fff24f53 doc: fix simd doc 2026-02-28 16:11:07 +01:00
Samuel Berthe 578bfa9ee7 doc: fix sidebar 2026-02-28 02:29:57 +01:00
Samuel Berthe c767d0d8ca doc: fix sidebar 2026-02-28 02:25:49 +01:00
d-enk 68f827d9bf perf: optimize Substring to work directly with strings instead of converting to runes (#822)
* perf: optimize Substring to work directly with strings instead of converting to runes

- Rewrite Substring to iterate over string bytes directly, avoiding full []rune conversion
- Improve performance for long strings by only processing necessary portions
- Add comprehensive test cases for Unicode handling, invalid UTF-8, and edge cases
- Add BenchmarkSubstring to measure performance improvements
- Improve documentation with detailed parameter descriptions
- Handle invalid UTF-8 sequences by converting to []rune when needed

Bencstat:

                   │    old.txt    │               new.txt               │
                   │    sec/op     │    sec/op     vs base               │
Substring/{10_10}-4    558.85n ±  9%   39.75n ± 10%  -92.89% (p=0.000 n=8)
Substring/{50_50}-4    783.10n ±  6%   85.15n ±  5%  -89.13% (p=0.000 n=8)
Substring/{50_45}-4    773.30n ±  3%   126.5n ±  7%  -83.65% (p=0.000 n=8)
Substring/{-50_50}-4   794.00n ±  2%   177.6n ±  7%  -77.63% (p=0.000 n=8)
Substring/{-10_10}-4   542.85n ± 20%   41.82n ±  6%  -92.30% (p=0.000 n=8)
geomean               680.4n         79.52n        -88.31%

                   │  old.txt   │               new.txt                │
                   │    B/op    │   B/op    vs base                    │
Substring/{10_10}-4    432.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)
Substring/{50_50}-4    480.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)
Substring/{50_45}-4    464.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)
Substring/{-50_50}-4   480.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)
Substring/{-10_10}-4   432.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)

                   │  old.txt   │                new.txt                 │
                   │ allocs/op  │ allocs/op   vs base                    │
Substring/{10_10}-4    2.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)
Substring/{50_50}-4    2.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)
Substring/{50_45}-4    2.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)
Substring/{-50_50}-4   2.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)
Substring/{-10_10}-4   2.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)

* Enhance substring documentation with Unicode details

Returns a substring starting at the given offset with the specified length. Supports negative offsets; out-of-bounds are clamped. Operates on Unicode runes (characters) and is optimized for zero allocations.

---------

Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
2026-02-27 22:19:20 +01:00
Samuel Berthe ac8295b68a style(simd): rename sse to avx (#821)
* style(simd): rename sse to avx

* fix(exp,simd): apply the right avx512 constraints to a few methods

* fix(exp,simd): apply the right avx512 constraints to a few methods
2026-02-26 22:08:53 +01:00
d-enk c49f84658a perf: lazy it.Reverse iteration instead of in-place mutation (#814)
Replace mutable.Reverse() with lazy iteration from end.
This avoids unnecessary array mutation and reduces overhead.
2026-02-25 20:59:44 +01:00
d-enk b9c84bc078 perf: optimize Zip and ZipBy functions (#818)
- Replace Nth() with NthOrEmpty() to avoid unnecessary error allocation on miss
- Change make(0, size) + append to make(size) + direct assignment
- Use uint for loop indices
- Remove temporary variables in ZipBy functions

This reduces overhead from append operations and structure creation,
similar to the Zip5Copy2 optimization pattern.

Reduces code size: +174/-242 lines
2026-02-25 20:57:04 +01:00
d-enk b27b00635d perf: avoid unnecessary error allocation in NthOr, NthOrEmpty (#817)
Extract core logic into sliceNth/seqNth func returning (T, bool) instead of (T, error).

NthOr and NthOrEmpty now use these directly,
avoiding fmt.Errorf allocation when nth is out of bounds.
2026-02-25 20:50:51 +01:00
d-enk b0b5cc3adf perf: preallocate result slice in RangeWithSteps (#820)
- RangeWithSteps now preallocates result slice using math.Ceil for better performance
- Fix edge cases for floating point values with small steps
- Add test cases for float and custom type validation
- Rename TestRangeClose → TestRangeWithSteps for consistency
- Simplify ChunkEntries chunk count calculation using ((count-1)/size)+1 formula
2026-02-25 20:48:26 +01:00
Samuel Berthe 41cfa4c55a chore(ci): use last go version with codeql 2026-02-25 20:25:36 +01:00
Samuel Berthe 84beb70d2e oops 2026-02-25 19:08:19 +01:00
Samuel Berthe 2554fc697a chore(ci): adding codeql (#819) 2026-02-25 19:05:32 +01:00
d-enk d0901349e7 perf: optimize it.ContainsBy, EveryBy, SomeBy, NoneBy to avoid unnecessary allocations (#812)
Replace intermediate iterator chains with direct loops and early returns.

The direct loops with early return eliminate intermediate iterator
creation from Filter(), Reject(), IsNotEmpty() and IsEmpty() functions.

Benchmark results (benchstat):
                         │    old.txt    │               new.txt               │
                         │    sec/op     │    sec/op     vs base               │
ItContainsBy/ints_10-4      807.2n ± 54%   151.0n ±  6%  -81.29% (p=0.000 n=8)
ItContainsBy/ints_100-4     2.447µ ± 14%   1.531µ ± 11%  -37.42% (p=0.000 n=8)
ItContainsBy/ints_1000-4    17.67µ ±  4%   13.85µ ±  4%  -21.64% (p=0.000 n=8)
ItEveryBy/ints_10-4        1022.5n ± 63%   208.0n ± 34%  -79.66% (p=0.000 n=8)
ItEveryBy/ints_100-4        5.640µ ± 36%   1.542µ ±  9%  -72.67% (p=0.000 n=8)
ItEveryBy/ints_1000-4       52.22µ ± 54%   19.29µ ± 16%  -63.06% (p=0.000 n=8)
ItSomeBy/ints_10-4         2227.5n ± 43%   187.1n ± 14%  -91.60% (p=0.000 n=8)
ItSomeBy/ints_100-4         4.611µ ± 22%   1.691µ ± 10%  -63.32% (p=0.000 n=8)
ItSomeBy/ints_1000-4        39.41µ ± 27%   22.61µ ± 24%  -42.63% (p=0.000 n=8)
ItNoneBy/ints_10-4         1657.5n ± 34%   196.3n ± 21%  -88.15% (p=0.000 n=8)
ItNoneBy/ints_100-4         4.503µ ± 20%   1.743µ ± 12%  -61.30% (p=0.000 n=8)
ItNoneBy/ints_1000-4        29.39µ ± 29%   16.66µ ± 15%  -43.32% (p=0.000 n=8)
geomean                     5.591µ         1.747µ        -68.76%

                         │  old.txt   │               new.txt                │
                         │    B/op    │   B/op    vs base                    │
ItContainsBy/ints_10-4     200.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)
ItContainsBy/ints_100-4    200.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)
ItContainsBy/ints_1000-4   200.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)
ItEveryBy/ints_10-4        184.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)
ItEveryBy/ints_100-4       184.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)
ItEveryBy/ints_1000-4      184.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)
ItSomeBy/ints_10-4         200.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)
ItSomeBy/ints_100-4        200.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)
ItSomeBy/ints_1000-4       200.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)
ItNoneBy/ints_10-4         200.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)
ItNoneBy/ints_100-4        200.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)
ItNoneBy/ints_1000-4       200.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)

                         │  old.txt   │                new.txt                 │
                         │ allocs/op  │ allocs/op   vs base                    │
ItContainsBy/ints_10-4     7.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)
ItContainsBy/ints_100-4    7.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)
ItContainsBy/ints_1000-4   7.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)
ItEveryBy/ints_10-4        6.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)
ItEveryBy/ints_100-4       6.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)
ItEveryBy/ints_1000-4      6.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)
ItSomeBy/ints_10-4         7.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)
ItSomeBy/ints_100-4        7.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)
ItSomeBy/ints_1000-4       7.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)
ItNoneBy/ints_10-4         7.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)
ItNoneBy/ints_100-4        7.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)
ItNoneBy/ints_1000-4       7.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)

Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
2026-02-24 20:26:59 +01:00
d-enk b33df06020 perf: optimize it.Find to avoid unnecessary allocations (#811)
Replace First(Filter(collection, predicate)) with direct loop implementation.

The direct loop with early return eliminates intermediate iterator
creation from Filter() and First() functions.

Benchmark results:
                   │   old.txt    │               new.txt               │
                   │    sec/op    │    sec/op     vs base               │
ItFind/ints_10-4     521.3n ± 14%   157.3n ±  8%  -69.82% (p=0.000 n=8)
ItFind/ints_100-4    1.913µ ± 13%   1.545µ ± 22%  -19.26% (p=0.002 n=8)
ItFind/ints_1000-4   17.07µ ±  7%   12.88µ ±  1%  -24.59% (p=0.000 n=8)
geomean              2.573µ         1.462µ        -43.15%

                   │  old.txt   │               new.txt                │
                   │    B/op    │   B/op    vs base                    │
ItFind/ints_10-4     192.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)
ItFind/ints_100-4    192.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)
ItFind/ints_1000-4   192.0 ± 0%   0.0 ± 0%  -100.00% (p=0.000 n=8)

                   │  old.txt   │                new.txt                 │
                   │ allocs/op  │ allocs/op   vs base                    │
ItFind/ints_10-4     7.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)
ItFind/ints_100-4    7.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)
ItFind/ints_1000-4   7.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=8)

Co-authored-by: Samuel Berthe <dev@samuel-berthe.fr>
2026-02-24 20:25:28 +01:00