forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit849110d
committed
Optimize sifting down in binaryheap.
Presently, each iteration of the loop in sift_down() will perform3 comparisons if both children are larger than the parent node (2for comparing each child to the parent node, and a third to comparethe children to each other). By first comparing the children toeach other and then comparing the larger child to the parent node,we can accomplish the same thing with just 2 comparisons (whilealso not affecting the number of comparisons in any other case).Author: ChangAo ChenReviewed-by: Robert HaasDiscussion:https://postgr.es/m/tencent_0142D8DA90940B9930BCC08348BBD6D0BB07%40qq.com1 parentaf21152 commit849110d
1 file changed
+9
-20
lines changedLines changed: 9 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
323 | 323 |
| |
324 | 324 |
| |
325 | 325 |
| |
326 |
| - | |
| 326 | + | |
327 | 327 |
| |
328 |
| - | |
329 |
| - | |
330 |
| - | |
331 |
| - | |
332 |
| - | |
333 |
| - | |
334 |
| - | |
335 |
| - | |
| 328 | + | |
336 | 329 |
| |
337 |
| - | |
| 330 | + | |
338 | 331 |
| |
339 | 332 |
| |
340 |
| - | |
341 |
| - | |
342 |
| - | |
343 |
| - | |
344 |
| - | |
345 |
| - | |
346 |
| - | |
347 |
| - | |
| 333 | + | |
348 | 334 |
| |
349 | 335 |
| |
350 |
| - | |
| 336 | + | |
351 | 337 |
| |
352 | 338 |
| |
353 |
| - | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
354 | 343 |
| |
355 | 344 |
| |
356 | 345 |
| |
|
0 commit comments
Comments
(0)