Bläddra i källkod

LibJS: Pre-size the hash map and vector used in ensure_property_table()

Andreas Kling 4 år sedan
förälder
incheckning
ad0d377e4c
1 ändrade filer med 2 tillägg och 1 borttagningar
  1. 2 1
      Libraries/LibJS/Runtime/Shape.cpp

+ 2 - 1
Libraries/LibJS/Runtime/Shape.cpp

@@ -148,10 +148,11 @@ void Shape::ensure_property_table() const
     if (m_property_table)
     if (m_property_table)
         return;
         return;
     m_property_table = make<HashMap<StringOrSymbol, PropertyMetadata>>();
     m_property_table = make<HashMap<StringOrSymbol, PropertyMetadata>>();
+    m_property_table->ensure_capacity(m_property_count);
 
 
     DeferGC defer(heap());
     DeferGC defer(heap());
 
 
-    Vector<const Shape*> transition_chain;
+    Vector<const Shape*, 64> transition_chain;
     for (auto* shape = this; shape->m_previous; shape = shape->m_previous) {
     for (auto* shape = this; shape->m_previous; shape = shape->m_previous) {
         transition_chain.append(shape);
         transition_chain.append(shape);
     }
     }