Browse Source

Avoid unnecessary definition updates when adding or removing documents

Michael Ragazzon 3 years ago
parent
commit
bd9fbd0955
1 changed files with 6 additions and 0 deletions
  1. 6 0
      Source/Core/Context.cpp

+ 6 - 0
Source/Core/Context.cpp

@@ -191,6 +191,12 @@ bool Context::Update()
 	for (auto& data_model : data_models)
 		data_model.second->Update(true);
 
+	// The style definition of each document should be independent of each other. By manually resetting these flags we avoid unnecessary definition
+	// lookups in unrelated documents, such as when adding a new document. Adding an element dirties the parent definition, which in this case is the
+	// root. By extension the definition of all the other documents are also dirtied, unnecessarily.
+	root->dirty_definition = false;
+	root->dirty_child_definitions = false;
+
 	root->Update(density_independent_pixel_ratio, Vector2f(dimensions));
 
 	for (int i = 0; i < root->GetNumChildren(); ++i)