Skip to content

Commit 6ace3a6

Browse files
committed
perf: simplify layout calculation
Signed-off-by: Andres Correa Casablanca <castarco@coderspirit.xyz>
1 parent 9a9d110 commit 6ace3a6

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/layouts.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,12 @@ const _computeLeftShiftLayout = (
1010
tree: Tree,
1111
depth = 0,
1212
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
13-
counters: { layers: number[][]; maxX: number },
13+
counters: { layers: number[]; maxX: number },
1414
): Readonly<TreeWithLayout> => {
1515
const layers = counters.layers
1616

17-
if (layers[depth] === undefined) {
18-
layers[depth] = []
19-
}
20-
const x = (layers[depth]?.at(-1) ?? -1) + 1
21-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
22-
layers[depth]!.push(x)
17+
const x = (layers[depth] ?? -1) + 1
18+
layers[depth] = x
2319
counters.maxX = Math.max(counters.maxX, x)
2420

2521
return {

0 commit comments

Comments
 (0)