@@ -319,13 +319,13 @@ So merging is always done on two consecutive runs at a time, and in-place,
319
319
although this may require some temp memory (more on that later).
320
320
321
321
When a run is identified, its base address and length are pushed on a stack
322
- in the MergeState struct. merge_collapse() is then called to see whether it
323
- should merge it with preceding run(s) . We would like to delay merging as
324
- long as possible in order to exploit patterns that may come up later, but we
325
- like even more to do merging as soon as possible to exploit that the run just
326
- found is still high in the memory hierarchy. We also can't delay merging
327
- "too long" because it consumes memory to remember the runs that are still
328
- unmerged, and the stack has a fixed size.
322
+ in the MergeState struct. merge_collapse() is then called to potentially
323
+ merge runs on that stack . We would like to delay merging as long as possible
324
+ in order to exploit patterns that may come up later, but we like even more to
325
+ do merging as soon as possible to exploit that the run just found is still
326
+ high in the memory hierarchy. We also can't delay merging "too long" because
327
+ it consumes memory to remember the runs that are still unmerged, and the
328
+ stack has a fixed size.
329
329
330
330
What turned out to be a good compromise maintains two invariants on the
331
331
stack entries, where A, B and C are the lengths of the three rightmost not-yet
@@ -739,7 +739,7 @@ slice (leaving off both endpoints) (2**(k-1)-1)+1 through (2**k-1)-1
739
739
inclusive = 2**(k-1) through (2**k-1)-1 inclusive, which has
740
740
(2**k-1)-1 - 2**(k-1) + 1 =
741
741
2**k-1 - 2**(k-1) =
742
- 2*2**k -1 - 2**(k-1) =
742
+ 2*2**(k-1) -1 - 2**(k-1) =
743
743
(2-1)*2**(k-1) - 1 =
744
744
2**(k-1) - 1
745
745
elements.
0 commit comments