Skip to content

Commit

Permalink
Use static values for undefined and auto lengths
Browse files Browse the repository at this point in the history
Summary:
X-link: facebook/yoga#1734

X-link: facebook/litho#1030

Profiling in a test app with many undefined lengths shows this saves roughly 33% of time spent in Yoga.

## Changelog

[General][Fixed] Reduce amount of time spent in Yoga by reusing statically defined values in StyleLength::getLength()

Reviewed By: yungsters

Differential Revision: D65207753
  • Loading branch information
rozele authored and facebook-github-bot committed Oct 30, 2024
1 parent a85955a commit 2b9ef68
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ class StyleValuePool {

StyleLength getLength(StyleValueHandle handle) const {
if (handle.isUndefined()) {
return StyleLength::undefined();
static StyleLength undefined = StyleLength::undefined();
return undefined;
} else if (handle.isAuto()) {
return StyleLength::ofAuto();
static StyleLength ofAuto = StyleLength::ofAuto();
return ofAuto;
} else {
assert(
handle.type() == StyleValueHandle::Type::Point ||
Expand Down

0 comments on commit 2b9ef68

Please sign in to comment.