Commit 676ff8f
Avoid redundant dynamic_pointer_cast in YogaLayoutableShadowNode clone (#57019)
Summary:
The clone constructor of `YogaLayoutableShadowNode` rebuilt the
internal `yogaLayoutableChildren_` vector on every clone by
walking every child with `dynamic_pointer_cast`. When the cloned
node inherits its children list from the source (`!fragment.children`)
the result is identical to the source's vector, so copy it directly
instead — no RTTI required.
Also `reserve()` the vector to its upper bound at the top of
`updateYogaChildren()` so the rebuild on the new-children path no
longer reallocates as it grows.
Both changes are pure CPU-time optimizations on a hot path that
shows up heavily in animation-driven tree clones; behaviour is
unchanged.
Changelog:
[Internal]
Reviewed By: christophpurrer, lenaic
Differential Revision: D1062871711 parent 64c9663 commit 676ff8f
1 file changed
Lines changed: 14 additions & 5 deletions
File tree
- packages/react-native/ReactCommon/react/renderer/components/view
Lines changed: 14 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
122 | 130 | | |
123 | 131 | | |
124 | 132 | | |
| |||
349 | 357 | | |
350 | 358 | | |
351 | 359 | | |
| 360 | + | |
352 | 361 | | |
353 | 362 | | |
354 | 363 | | |
| |||
0 commit comments