Browse Source

Reserve sizes

Michael Ragazzon 6 years ago
parent
commit
b06225ecba
2 changed files with 5 additions and 3 deletions
  1. 1 0
      Source/Core/Element.cpp
  2. 4 3
      Source/Core/ElementAnimation.cpp

+ 1 - 0
Source/Core/Element.cpp

@@ -998,6 +998,7 @@ void Element::SetAttributes(const ElementAttributes* _attributes)
 	Variant* value;
 	Variant* value;
 
 
 	AttributeNameList changed_attributes;
 	AttributeNameList changed_attributes;
+	changed_attributes.reserve(_attributes->Size());
 
 
 	while (_attributes->Iterate(index, key, value))
 	while (_attributes->Iterate(index, key, value))
 	{		
 	{		

+ 4 - 3
Source/Core/ElementAnimation.cpp

@@ -117,9 +117,6 @@ static Property InterpolateProperties(const Property & p0, const Property& p1, f
 	{
 	{
 		using namespace Rocket::Core::Transforms;
 		using namespace Rocket::Core::Transforms;
 
 
-		// Build the new, interpolating transform
-		auto t = std::make_unique<Transform>();
-
 		auto t0 = p0.value.Get<TransformRef>();
 		auto t0 = p0.value.Get<TransformRef>();
 		auto t1 = p1.value.Get<TransformRef>();
 		auto t1 = p1.value.Get<TransformRef>();
 
 
@@ -132,6 +129,10 @@ static Property InterpolateProperties(const Property & p0, const Property& p1, f
 			return Property{ t0, Property::TRANSFORM };
 			return Property{ t0, Property::TRANSFORM };
 		}
 		}
 
 
+		// Build the new, interpolating transform
+		auto t = std::make_unique<Transform>();
+		t->GetPrimitives().reserve(t0->GetPrimitives().size());
+
 		for (size_t i = 0; i < prim0.size(); i++)
 		for (size_t i = 0; i < prim0.size(); i++)
 		{
 		{
 			Primitive p = prim0[i];
 			Primitive p = prim0[i];