Skip to content

Commit

Permalink
In YogaUIView's layoutNodes method, return early for nested YogaUIVie…
Browse files Browse the repository at this point in the history
…ws to prevent redundant frame calculations. (#1999)

Follow-up to PR #1996
  • Loading branch information
dnagler authored May 1, 2024
1 parent 75c812f commit cd0d58d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Fixed:
- Avoid calling into the internal Zipline instance from the UI thread on startup. This would manifest as weird native crashes due to multiple threads mutating shared memory.
- In `UIViewLazyList`, fix `UInt` to `UIColor` conversion math used for `pullRefreshContentColor`.
- In `YogaUIView`'s `setScrollEnabled` method, only call `setNeedsLayout` if the `scrollEnabled` value is actually changing.
- In `YogaUIView`'s `layoutNodes` method, return early for nested `YogaUIView`s to prevent redundant frame calculations.

Upgraded:
- Zipline 1.9.0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ internal class YogaUIView(
val height = node.height.toDouble()
node.view.setFrame(CGRectMake(x, y, width, height))

if (node.view is YogaUIView) {
// Optimization: for a YogaUIView nested within another YogaUIView,
// there's no need to call layoutNodes for its children here,
// as it will happen within its own layoutSubviews() pass.
return
}

for (childNode in node.children) {
layoutNodes(childNode)
}
Expand Down

0 comments on commit cd0d58d

Please sign in to comment.