Commit b1f64df
Primitive double sort for numeric arrays in std.sort
Replace Comparator-based java.util.Arrays.sort with primitive double
sort (DualPivotQuicksort) for numeric arrays. Extracts doubles into
primitive array, sorts with intrinsic DualPivotQuicksort, reconstructs
Val.Num array via cachedNum. Eliminates Comparator virtual dispatch
and Double boxing per comparison.
Also optimizes with-key-function path: extracts doubles into primitive
array for unboxed comparison via sortWith instead of boxed sortBy.
Benchmark (bench.06 sort, -f1 -wi12 -i12):
Before: 5.261 ± 6.115 ms/op
After: 3.222 ± 0.170 ms/op (-38.7%)
Regression suite also shows improvement in set operations:
setDiff: 0.700 → 0.499 ms/op
setInter: 0.608 → 0.434 ms/op
setUnion: 0.915 → 0.720 ms/op
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent d60ba61 commit b1f64df
1 file changed
Lines changed: 14 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
117 | 121 | | |
118 | 122 | | |
119 | 123 | | |
| |||
152 | 156 | | |
153 | 157 | | |
154 | 158 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
163 | 168 | | |
164 | 169 | | |
165 | 170 | | |
| |||
0 commit comments