Skip to content

Commit

Permalink
Remove usage of Array#fill (facebook#20071)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Oct 22, 2020
1 parent 89b6109 commit 8e5adfb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/react-reconciler/src/ReactFiberLane.js
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,13 @@ export function higherLanePriority(
}

export function createLaneMap<T>(initial: T): LaneMap<T> {
return new Array(TotalLanes).fill(initial);
// Intentionally pushing one by one.
// https://v8.dev/blog/elements-kinds#avoid-creating-holes
const laneMap = [];
for (let i = 0; i < TotalLanes; i++) {
laneMap.push(initial);
}
return laneMap;
}

export function markRootUpdated(
Expand Down

0 comments on commit 8e5adfb

Please sign in to comment.