Skip to content

Commit 00d9e87

Browse files
rozelefacebook-github-bot
authored andcommitted
Use static values for undefined and auto lengths
Summary: 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
1 parent d4e82f9 commit 00d9e87

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/yoga/src/main/cpp/yoga/style/StyleValuePool.h

+4-2
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 StyleLength undefined = StyleLength::undefined();
53+
return undefined;
5354
} else if (handle.isAuto()) {
54-
return StyleLength::ofAuto();
55+
static StyleLength ofAuto = StyleLength::ofAuto();
56+
return ofAuto;
5557
} else {
5658
assert(
5759
handle.type() == StyleValueHandle::Type::Point ||

0 commit comments

Comments
 (0)