Skip to content

Commit

Permalink
chore: fastest way to create deltas array
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Aug 15, 2023
1 parent d0be900 commit be939b9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/fork-choice/src/protoArray/computeDeltas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ export function computeDeltas(
newBalances: EffectiveBalanceIncrements,
equivocatingIndices: Set<ValidatorIndex>
): number[] {
const deltas = Array<number>(numProtoNodes).fill(0);
const deltas = new Array<number>(numProtoNodes);
for (let i = 0; i < numProtoNodes; i++) {
deltas[i] = 0;
}

// avoid creating new variables in the loop to potentially reduce GC pressure
let oldBalance, newBalance: number;
let currentIndex, nextIndex: number | null;
Expand Down

0 comments on commit be939b9

Please sign in to comment.