Skip to content

The agent that grows with you

perf(tui): skip cached rounding subtrees before descent

fangliquanb363fee510a0
diff --git a/ui-tui/packages/hermes-ink/src/native-ts/yoga-layout/index.ts b/ui-tui/packages/hermes-ink/src/native-ts/yoga-layout/index.ts
index 5e954e99030..2333931237e 100644
--- a/ui-tui/packages/hermes-ink/src/native-ts/yoga-layout/index.ts
+++ b/ui-tui/packages/hermes-ink/src/native-ts/yoga-layout/index.ts
@@ -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) {
diff --git a/ui-tui/packages/hermes-ink/src/native-ts/yoga-layout/round-layout.test.ts b/ui-tui/packages/hermes-ink/src/native-ts/yoga-layout/round-layout.test.ts
index f49d7879675..12f7b359270 100644
--- a/ui-tui/packages/hermes-ink/src/native-ts/yoga-layout/round-layout.test.ts
+++ b/ui-tui/packages/hermes-ink/src/native-ts/yoga-layout/round-layout.test.ts
@@ -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)