Don't preallocate child lists
Summary: There is no reason to malloc a list of 4 child pointers for every CSS node eagerly. Instead, we malloc the list (preserving the default size of 4) when we try to put stuff in it. Reviewed By: emilsjolander Differential Revision: D4078012 fbshipit-source-id: 7cdcab03ec4067550a5fee5e1baea14344f3a8f9
This commit is contained in:
committed by
Facebook Github Bot
parent
0cc1b83569
commit
01c2ac3369
@@ -195,7 +195,7 @@ int32_t CSSNodeGetInstanceCount(void) {
|
||||
|
||||
void CSSNodeInit(const CSSNodeRef node) {
|
||||
node->parent = NULL;
|
||||
node->children = CSSNodeListNew(4);
|
||||
node->children = NULL;
|
||||
node->hasNewLayout = true;
|
||||
node->isDirty = false;
|
||||
|
||||
@@ -257,7 +257,7 @@ static void _CSSNodeMarkDirty(const CSSNodeRef node) {
|
||||
|
||||
void CSSNodeInsertChild(const CSSNodeRef node, const CSSNodeRef child, const uint32_t index) {
|
||||
CSS_ASSERT(child->parent == NULL, "Child already has a parent, it must be removed first.");
|
||||
CSSNodeListInsert(node->children, child, index);
|
||||
CSSNodeListInsert(&node->children, child, index);
|
||||
child->parent = node;
|
||||
_CSSNodeMarkDirty(node);
|
||||
}
|
||||
|
Reference in New Issue
Block a user