Skip to content

Commit

Permalink
Use zero-fill right shift instead of Math.floor (#17616)
Browse files Browse the repository at this point in the history
For positive numbers, binary displacement is better.
  • Loading branch information
yisar authored and acdlite committed Dec 17, 2019
1 parent 9bb3fbe commit 7309c5f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/scheduler/src/SchedulerMinHeap.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function pop(heap: Heap): Node | null {
function siftUp(heap, node, i) {
let index = i;
while (true) {
const parentIndex = Math.floor((index - 1) / 2);
const parentIndex = (index - 1) >>> 1;
const parent = heap[parentIndex];
if (parent !== undefined && compare(parent, node) > 0) {
// The parent is larger. Swap positions.
Expand Down

0 comments on commit 7309c5f

Please sign in to comment.