@samitouri / QOS-React / commits / 7309c5f934

Use zero-fill right shift instead of Math.floor (#17616)

For positive numbers, binary displacement is better.

伊撒尔 committed Dec 18, 2019 at 03:16 UTC 7309c5f93469266729578f1d0e0d273604b45da4
1 file changed +1 -1
packages/scheduler/src/SchedulerMinHeap.js
+1 -1
@@ -41,7 +41,7 @@ export function pop(heap: Heap): Node | null {
41 function siftUp(heap, node, i) {
42 let index = i;
43 while (true) {
44 - const parentIndex = Math.floor((index - 1) / 2);
44 + const parentIndex = (index - 1) >>> 1;
45 const parent = heap[parentIndex];
46 if (parent !== undefined && compare(parent, node) > 0) {
47 // The parent is larger. Swap positions.