Commit 75ccb01
authored
Improve performance by optimizing bundle merging logic. (#204)
While merging two bundles, the `merge_bundles` function appends two
sorted vectors and sort the resulting vector again. This approach used
to be fast in most cases, but rustc 1.81 introduced changes in sorting
algorithm that made `sort_unstable_by_key` to behave very bad with
vectors that are almost sorted.
This introduces an optimization consisting in handling the special case
where the vector being appended contains a single item differently. This
case is very common, and there's a benefit in handling it differently
both with rust 1.81 and with earlier versions.
Fixes #2031 parent a3296d0 commit 75ccb01
2 files changed
+24
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | | - | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | 173 | | |
177 | | - | |
| 174 | + | |
178 | 175 | | |
179 | 176 | | |
180 | 177 | | |
181 | 178 | | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
186 | 200 | | |
187 | 201 | | |
188 | 202 | | |
| |||
0 commit comments