Skip to content

Commit a2138b7

Browse files
rozelefacebook-github-bot
authored andcommitted
Use static values for undefined and auto lengths (facebook#47305)
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, mdvacca Differential Revision: D65207753
1 parent a85955a commit a2138b7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/react-native/ReactCommon/yoga/yoga/style/StyleValuePool.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ class StyleValuePool {
4949

5050
StyleLength getLength(StyleValueHandle handle) const {
5151
if (handle.isUndefined()) {
52-
return StyleLength::undefined();
52+
static const StyleLength undefined = StyleLength::undefined();
53+
return undefined;
5354
} else if (handle.isAuto()) {
54-
return StyleLength::ofAuto();
55+
static const StyleLength ofAuto = StyleLength::ofAuto();
56+
return ofAuto;
5557
} else {
5658
assert(
5759
handle.type() == StyleValueHandle::Type::Point ||

0 commit comments

Comments
 (0)