perf(tui): skip cached rounding subtrees before descent

This commit is contained in:
fangliquan
2026-08-17 02:59:08 +08:00
committed by kshitij
parent bbbd3b100f
commit b363fee510
2 changed files with 10 additions and 8 deletions
@@ -979,13 +979,6 @@ function layoutNode(
if (performLayout) {
node._rLayoutGen = _generation
let ancestor: Node | null = node
while (ancestor && ancestor._rSubtreeLayoutGen !== _generation) {
ancestor._rSubtreeLayoutGen = _generation
ancestor = ancestor.parent
}
}
const style = node.style
@@ -1056,6 +1049,15 @@ function layoutNode(
}
}
if (performLayout) {
let ancestor: Node | null = node
while (ancestor && ancestor._rSubtreeLayoutGen !== _generation) {
ancestor._rSubtreeLayoutGen = _generation
ancestor = ancestor.parent
}
}
const wasDirty = node.isDirty_
if (performLayout) {
@@ -74,7 +74,7 @@ describe('incremental layout rounding', () => {
expect(clock.getComputedWidth()).toBe(6.5)
expect(transcript.getComputedWidth()).toBe(transcriptWidth)
expect(counters.rounded).toBeLessThanOrEqual(4)
expect(counters.roundSkips).toBeGreaterThanOrEqual(1)
expect(counters.roundSkips).toBe(1)
root.freeRecursive()
Yoga.Config.destroy(config)