forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit53d3daa
committed
Specialize intarray sorting
There is at least one report in the field of storing millions ofintegers in arrays, so it seems like a good time to specializeintarray's qsort function. In doing so, streamline the comparators:Previously there were three, two for each direction for sortingand one passed to qunique_arg. To preserve the early exit in thecase of descending input, pass the direction as an argument tothe comparator. This requires giving up duplicate detection, whichpreviously allowed skipping the qunique_arg() call. Testing showedno regressions this way.In passing, get rid of nearby checks that the input has at leasttwo elements, since preserving them would make some macros lessreadable. These are not necessary for correctness, and seem likepremature optimizations.Author: Andrey M. Borodin <x4mmm@yandex-team.ru>Discussion:https://postgr.es/m/098A3E67-E4A6-4086-9C66-B1EAEB1DFE1C@yandex-team.ru1 parent164bac9 commit53d3daa
2 files changed
+34
-48
lines changedLines changed: 8 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
41 | 41 |
| |
42 | 42 |
| |
43 | 43 |
| |
44 |
| - | |
45 |
| - | |
| 44 | + | |
| 45 | + | |
46 | 46 |
| |
47 | 47 |
| |
48 | 48 |
| |
49 | 49 |
| |
50 | 50 |
| |
51 | 51 |
| |
52 |
| - | |
53 |
| - | |
54 |
| - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
55 | 55 |
| |
56 | 56 |
| |
57 | 57 |
| |
| |||
109 | 109 |
| |
110 | 110 |
| |
111 | 111 |
| |
112 |
| - | |
| 112 | + | |
113 | 113 |
| |
114 | 114 |
| |
115 | 115 |
| |
| |||
176 | 176 |
| |
177 | 177 |
| |
178 | 178 |
| |
179 |
| - | |
180 |
| - | |
181 |
| - | |
182 | 179 |
| |
183 | 180 |
| |
184 | 181 |
| |
185 | 182 |
| |
186 |
| - | |
187 |
| - | |
188 |
| - | |
| 183 | + | |
| 184 | + | |
189 | 185 |
| |
190 | 186 |
| |
191 | 187 |
|
Lines changed: 26 additions & 36 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
186 | 186 |
| |
187 | 187 |
| |
188 | 188 |
| |
189 |
| - | |
190 |
| - | |
| 189 | + | |
| 190 | + | |
191 | 191 |
| |
192 | 192 |
| |
193 | 193 |
| |
194 | 194 |
| |
195 | 195 |
| |
196 |
| - | |
197 |
| - | |
198 |
| - | |
199 |
| - | |
200 |
| - | |
201 |
| - | |
202 |
| - | |
203 |
| - | |
204 |
| - | |
205 |
| - | |
206 |
| - | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
207 | 211 |
| |
208 | 212 |
| |
209 | 213 |
| |
210 |
| - | |
211 |
| - | |
212 |
| - | |
213 |
| - | |
214 |
| - | |
215 |
| - | |
216 |
| - | |
217 |
| - | |
218 |
| - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
219 | 221 |
| |
220 | 222 |
| |
221 | 223 |
| |
| |||
311 | 313 |
| |
312 | 314 |
| |
313 | 315 |
| |
314 |
| - | |
| 316 | + | |
315 | 317 |
| |
316 | 318 |
| |
317 |
| - | |
| 319 | + | |
318 | 320 |
| |
319 | 321 |
| |
320 | 322 |
| |
| |||
393 | 395 |
| |
394 | 396 |
| |
395 | 397 |
| |
396 |
| - | |
397 |
| - | |
398 |
| - | |
399 |
| - | |
400 |
| - | |
401 |
| - | |
402 |
| - | |
403 |
| - | |
404 |
| - | |
405 |
| - | |
406 |
| - | |
407 |
| - |
0 commit comments
Comments
(0)