Skip to content

Commit 4187b25

Browse files
committed
perf: remove useless step
Signed-off-by: Andres Correa Casablanca <castarco@coderspirit.xyz>
1 parent a9d47d9 commit 4187b25

File tree

1 file changed

+4
-46
lines changed

1 file changed

+4
-46
lines changed

src/layouts.ts

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ const _inPlaceEvenSpacingUpdate = (
118118
numChildren: number,
119119
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
120120
tree: DeepWriteable<TreeWithLayout>,
121-
shift: number,
122121
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
123122
offsets: number[],
124123
depth: number,
@@ -128,20 +127,20 @@ const _inPlaceEvenSpacingUpdate = (
128127
const tm = tree.meta
129128
const tmp = tm.pos
130129
if (numChildren === 0) {
131-
tmp.x = M(offsets[depth] ?? 0, tmp.x + shift)
130+
tmp.x = M(offsets[depth] ?? 0, tmp.x)
132131
delete tm.m
133132
} else if (numChildren === 1) {
134133
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
135134
const c = _getPosX(tree[C]![0]!)
136-
tmp.x = M(offsets[depth] ?? 0, c + shift)
135+
tmp.x = M(offsets[depth] ?? 0, c)
137136
tm.m = tmp.x - c
138137
} else {
139138
const c = // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
140139
(_getPosX(tree[C]![0]!) +
141140
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
142141
_getPosX(tree[C]![numChildren - 1]!)) *
143142
0.5
144-
tmp.x = M(offsets[depth] ?? 0, c + shift)
143+
tmp.x = M(offsets[depth] ?? 0, c)
145144
tm.m = tmp.x - c
146145
}
147146
tracer.mX = M(tracer.mX, tmp.x)
@@ -208,45 +207,7 @@ const _siblingsEvenSpacing = (
208207
)
209208
}
210209

211-
_inPlaceEvenSpacingUpdate(numChildren, tree, 0, offsets, depth, tracer)
212-
}
213-
214-
const _cousinsEvenSpacing = (
215-
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
216-
tree: DeepWriteable<TreeWithLayout>,
217-
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
218-
offsets: number[],
219-
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
220-
tracer: { mX: number },
221-
depth = 0,
222-
shift = 0,
223-
): void => {
224-
const tc = tree[C]
225-
const numChildren = tc?.length ?? 0
226-
227-
const nextOffset = offsets[depth + 1]
228-
let accShift = shift
229-
if (
230-
numChildren >= 2 &&
231-
nextOffset !== undefined &&
232-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
233-
(tc![0]!.node[C]?.length ?? 0) === 0
234-
) {
235-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
236-
const mid = _getPosX(tc![1]!) - 1
237-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
238-
accShift = shift + M(0, mid - _getPosX(tc![0]!))
239-
}
240-
241-
for (const [idx, { node }] of (tc ?? []).entries()) {
242-
if (idx === 0) {
243-
_cousinsEvenSpacing(node, offsets, tracer, depth + 1, accShift)
244-
} else {
245-
_cousinsEvenSpacing(node, offsets, tracer, depth + 1, shift)
246-
}
247-
}
248-
249-
_inPlaceEvenSpacingUpdate(numChildren, tree, shift, offsets, depth, tracer)
210+
_inPlaceEvenSpacingUpdate(numChildren, tree, offsets, depth, tracer)
250211
}
251212

252213
export const computeSmartLayout = (
@@ -258,9 +219,6 @@ export const computeSmartLayout = (
258219
const t = _computeSmartLayout(tree, 0, offsets, tracer)
259220
_addMods(t, 0, tracer)
260221

261-
_cousinsEvenSpacing(t, [], tracer)
262-
_addMods(t, 0, tracer)
263-
264222
_siblingsEvenSpacing(t, [], tracer)
265223
_addMods(t, 0, tracer)
266224

0 commit comments

Comments
 (0)