Skip to content

Commit 7f8a32c

Browse files
committed
Change useFloyd heuristic to match comment
Comment says exceed, but this checks if it is less than the limit.
1 parent 8e5e4a8 commit 7f8a32c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sources/HeapModule/Heap.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ extension Heap {
363363

364364
guard newCount > origCount, newCount > 1 else {
365365
// If we didn't append, or the result is too small to violate heapness,
366-
// then we have nothing else to dp.
366+
// then we have nothing else to do.
367367
return
368368
}
369369

@@ -381,7 +381,7 @@ extension Heap {
381381
//
382382
// FIXME: Write a benchmark to verify this heuristic.
383383
let heuristicLimit = 2 * newCount / newCount._binaryLogarithm()
384-
let useFloyd = (newCount - origCount) < heuristicLimit
384+
let useFloyd = (newCount - origCount) > heuristicLimit
385385
_update { handle in
386386
if useFloyd {
387387
handle.heapify()

0 commit comments

Comments
 (0)