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 authored Oct 21, 2020
1 parent 40cfe1f commit 6f62abb
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 6f62abb

Please sign in to comment.