-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Makes Yoga threadsafed: #791
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -270,4 +270,13 @@ struct YGNode { | |
bool isNodeFlexible(); | ||
bool didUseLegacyFlag(); | ||
bool isLayoutTreeEqualToNode(const YGNode& node) const; | ||
|
||
private: | ||
YGNodeRef pRoot = nullptr; | ||
|
||
public: | ||
uint32_t gCurrentGenerationCount = 0; | ||
uint32_t gDepth = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can avoid storing
Similarly, we can additionally pass the generation via function calls as above, to avoid the need for a pointer from each node to the tree root, saving another 8 bytes. I suspect the approach used in this PR also breaks cloning, which uses a "copy on write" scheme. In this PR, the pointer to the root is overwritten by By removing the pointer to the tree root we can also drop the new method |
||
YGNodeRef getRoot(); | ||
void setChildRoot(YGNodeRef node); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably reduce the storage here to just 16-bits (
uint16_t
), saving 2 bytes overhead per node here, and inYGLayout
(saving another 4 bytes). Do we really need to track more than 65,535 generations?Since this is now a member, we probably shouldn't use the "g" (global) prefix. It might also be a good idea to make it private, with inlined access via: