JavaScriptCore:
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Feb 2009 00:27:14 +0000 (00:27 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Feb 2009 00:27:14 +0000 (00:27 +0000)
2009-02-02  Darin Adler  <darin@apple.com>

        Reviewed by Dave Hyatt.

        Bug 23676: Speed up uses of reserveCapacity on new vectors by adding a new reserveInitialCapacity
        https://bugs.webkit.org/show_bug.cgi?id=23676

        * API/JSObjectRef.cpp:
        (JSObjectCopyPropertyNames): Use reserveInitialCapacity.
        * parser/Lexer.cpp:
        (JSC::Lexer::Lexer): Ditto.
        (JSC::Lexer::clear): Ditto.

        * wtf/Vector.h: Added reserveInitialCapacity, a more efficient version of
        reserveCapacity for use when the vector is brand new (still size 0 with no
        capacity other than the inline capacity).

WebCore:

2009-02-02  Darin Adler  <darin@apple.com>

        Reviewed by Dave Hyatt.

        Bug 23676: Speed up uses of reserveCapacity on new vectors by adding a new reserveInitialCapacity
        https://bugs.webkit.org/show_bug.cgi?id=23676

        * bindings/js/JSCSSStyleDeclarationCustom.cpp:
        (WebCore::cssPropertyName):
        * css/CSSMutableStyleDeclaration.cpp:
        (WebCore::CSSMutableStyleDeclaration::CSSMutableStyleDeclaration):
        (WebCore::CSSMutableStyleDeclaration::removePropertiesInSet):
        * css/CSSPrimitiveValue.cpp:
        (WebCore::CSSPrimitiveValue::cssText):
        * css/CSSStyleDeclaration.cpp:
        (WebCore::CSSStyleDeclaration::copyPropertiesInSet):
        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::sortMatchedRules):
        * dom/Document.cpp:
        (WebCore::Document::formElementsState):
        * dom/NamedAttrMap.h:
        (WebCore::NamedAttrMap::reserveInitialCapacity):
        * editing/TextIterator.cpp:
        (WebCore::CharacterIterator::string):
        (WebCore::SearchBuffer::SearchBuffer):
        (WebCore::plainTextToMallocAllocatedBuffer):
        * editing/markup.cpp:
        (WebCore::joinMarkups):
        * history/HistoryItem.cpp:
        (WebCore::HistoryItem::HistoryItem):
        * html/HTMLTokenizer.cpp:
        (WebCore::Token::addAttribute):
        * loader/appcache/DOMApplicationCache.cpp:
        (WebCore::DOMApplicationCache::items):
        * page/SecurityOrigin.cpp:
        (WebCore::SecurityOrigin::toString):
        * page/mac/AccessibilityObjectWrapper.mm:
        (convertToVector):
        * platform/graphics/FontCache.cpp:
        (WebCore::FontCache::purgeInactiveFontData):
        (WebCore::FontCache::invalidate):
        * platform/network/FormData.cpp:
        (WebCore::FormData::deepCopy):
        * platform/network/HTTPHeaderMap.cpp:
        (WebCore::HTTPHeaderMap::copyData):
        * platform/network/ResourceRequestBase.cpp:
        (WebCore::ResourceRequestBase::copyData):
        * platform/network/mac/FormDataStreamMac.mm:
        (WebCore::formCreate):
        * xml/XPathNodeSet.cpp:
        (WebCore::XPath::NodeSet::sort):
        Use reserveInitialCapacity instead of of reserveCapacity in all these call sites,
        which are working on new vectors that are guaranteed not to be empty.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@40501 268f45cc-cd09-0410-ab3c-d52691b4dbfc

25 files changed:
JavaScriptCore/API/JSObjectRef.cpp
JavaScriptCore/ChangeLog
JavaScriptCore/parser/Lexer.cpp
JavaScriptCore/wtf/Vector.h
WebCore/ChangeLog
WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp
WebCore/css/CSSMutableStyleDeclaration.cpp
WebCore/css/CSSPrimitiveValue.cpp
WebCore/css/CSSStyleDeclaration.cpp
WebCore/css/CSSStyleSelector.cpp
WebCore/dom/Document.cpp
WebCore/dom/NamedAttrMap.h
WebCore/editing/TextIterator.cpp
WebCore/editing/markup.cpp
WebCore/history/HistoryItem.cpp
WebCore/html/HTMLTokenizer.cpp
WebCore/loader/appcache/DOMApplicationCache.cpp
WebCore/page/SecurityOrigin.cpp
WebCore/page/mac/AccessibilityObjectWrapper.mm
WebCore/platform/graphics/FontCache.cpp
WebCore/platform/network/FormData.cpp
WebCore/platform/network/HTTPHeaderMap.cpp
WebCore/platform/network/ResourceRequestBase.cpp
WebCore/platform/network/mac/FormDataStreamMac.mm
WebCore/xml/XPathNodeSet.cpp

index 67bb2a5..e81e512 100644 (file)
@@ -467,7 +467,7 @@ JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef ctx, JSObjectRef o
     jsObject->getPropertyNames(exec, array);
 
     size_t size = array.size();
-    propertyNames->array.reserveCapacity(size);
+    propertyNames->array.reserveInitialCapacity(size);
     for (size_t i = 0; i < size; ++i)
         propertyNames->array.append(JSRetainPtr<JSStringRef>(Adopt, OpaqueJSString::create(array[i].ustring()).releaseRef()));
     
index 6050abe..1c58de9 100644 (file)
@@ -1,3 +1,20 @@
+2009-02-02  Darin Adler  <darin@apple.com>
+
+        Reviewed by Dave Hyatt.
+
+        Bug 23676: Speed up uses of reserveCapacity on new vectors by adding a new reserveInitialCapacity
+        https://bugs.webkit.org/show_bug.cgi?id=23676
+
+        * API/JSObjectRef.cpp:
+        (JSObjectCopyPropertyNames): Use reserveInitialCapacity.
+        * parser/Lexer.cpp:
+        (JSC::Lexer::Lexer): Ditto.
+        (JSC::Lexer::clear): Ditto.
+
+        * wtf/Vector.h: Added reserveInitialCapacity, a more efficient version of
+        reserveCapacity for use when the vector is brand new (still size 0 with no
+        capacity other than the inline capacity).
+
 2009-01-30  Mark Rowe  <mrowe@apple.com>
 
         Rubber-stamped by Oliver Hunt.
index 22de4a0..c2880dc 100644 (file)
@@ -80,8 +80,8 @@ Lexer::Lexer(JSGlobalData* globalData)
     , m_globalData(globalData)
     , m_mainTable(JSC::mainTable)
 {
-    m_buffer8.reserveCapacity(initialReadBufferCapacity);
-    m_buffer16.reserveCapacity(initialReadBufferCapacity);
+    m_buffer8.reserveInitialCapacity(initialReadBufferCapacity);
+    m_buffer16.reserveInitialCapacity(initialReadBufferCapacity);
 }
 
 Lexer::~Lexer()
@@ -884,11 +884,11 @@ void Lexer::clear()
     m_identifiers.clear();
 
     Vector<char> newBuffer8;
-    newBuffer8.reserveCapacity(initialReadBufferCapacity);
+    newBuffer8.reserveInitialCapacity(initialReadBufferCapacity);
     m_buffer8.swap(newBuffer8);
 
     Vector<UChar> newBuffer16;
-    newBuffer16.reserveCapacity(initialReadBufferCapacity);
+    newBuffer16.reserveInitialCapacity(initialReadBufferCapacity);
     m_buffer16.swap(newBuffer16);
 
     m_isReparsing = false;
index 880b45d..1483129 100644 (file)
@@ -503,6 +503,7 @@ namespace WTF {
         void grow(size_t size);
         void resize(size_t size);
         void reserveCapacity(size_t newCapacity);
+        void reserveInitialCapacity(size_t initialCapacity);
         void shrinkCapacity(size_t newCapacity);
         void shrinkToFit() { shrinkCapacity(size()); }
 
@@ -733,6 +734,15 @@ namespace WTF {
     }
     
     template<typename T, size_t inlineCapacity>
+    inline void Vector<T, inlineCapacity>::reserveInitialCapacity(size_t initialCapacity)
+    {
+        ASSERT(!m_size);
+        ASSERT(capacity() == inlineCapacity);
+        if (initialCapacity > inlineCapacity)
+            m_buffer.allocateBuffer(initialCapacity);
+    }
+    
+    template<typename T, size_t inlineCapacity>
     void Vector<T, inlineCapacity>::shrinkCapacity(size_t newCapacity)
     {
         if (newCapacity >= capacity())
index 263d8f5..c7a2620 100644 (file)
@@ -1,15 +1,69 @@
+2009-02-02  Darin Adler  <darin@apple.com>
+
+        Reviewed by Dave Hyatt.
+
+        Bug 23676: Speed up uses of reserveCapacity on new vectors by adding a new reserveInitialCapacity
+        https://bugs.webkit.org/show_bug.cgi?id=23676
+
+        * bindings/js/JSCSSStyleDeclarationCustom.cpp:
+        (WebCore::cssPropertyName):
+        * css/CSSMutableStyleDeclaration.cpp:
+        (WebCore::CSSMutableStyleDeclaration::CSSMutableStyleDeclaration):
+        (WebCore::CSSMutableStyleDeclaration::removePropertiesInSet):
+        * css/CSSPrimitiveValue.cpp:
+        (WebCore::CSSPrimitiveValue::cssText):
+        * css/CSSStyleDeclaration.cpp:
+        (WebCore::CSSStyleDeclaration::copyPropertiesInSet):
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::sortMatchedRules):
+        * dom/Document.cpp:
+        (WebCore::Document::formElementsState):
+        * dom/NamedAttrMap.h:
+        (WebCore::NamedAttrMap::reserveInitialCapacity):
+        * editing/TextIterator.cpp:
+        (WebCore::CharacterIterator::string):
+        (WebCore::SearchBuffer::SearchBuffer):
+        (WebCore::plainTextToMallocAllocatedBuffer):
+        * editing/markup.cpp:
+        (WebCore::joinMarkups):
+        * history/HistoryItem.cpp:
+        (WebCore::HistoryItem::HistoryItem):
+        * html/HTMLTokenizer.cpp:
+        (WebCore::Token::addAttribute):
+        * loader/appcache/DOMApplicationCache.cpp:
+        (WebCore::DOMApplicationCache::items):
+        * page/SecurityOrigin.cpp:
+        (WebCore::SecurityOrigin::toString):
+        * page/mac/AccessibilityObjectWrapper.mm:
+        (convertToVector):
+        * platform/graphics/FontCache.cpp:
+        (WebCore::FontCache::purgeInactiveFontData):
+        (WebCore::FontCache::invalidate):
+        * platform/network/FormData.cpp:
+        (WebCore::FormData::deepCopy):
+        * platform/network/HTTPHeaderMap.cpp:
+        (WebCore::HTTPHeaderMap::copyData):
+        * platform/network/ResourceRequestBase.cpp:
+        (WebCore::ResourceRequestBase::copyData):
+        * platform/network/mac/FormDataStreamMac.mm:
+        (WebCore::formCreate):
+        * xml/XPathNodeSet.cpp:
+        (WebCore::XPath::NodeSet::sort):
+        Use reserveInitialCapacity instead of of reserveCapacity in all these call sites,
+        which are working on new vectors that are guaranteed not to be empty.
+
 2009-02-26  Jon Honeycutt  <jhoneycutt@apple.com>
 
         Build fix after r40486.
 
         Rubber-stamped by Ada Chan.
 
-        * dom/Document.h:
-        * page/EventHandler.h:
-        * rendering/EllipsisBox.h:
-        * rendering/InlineBox.h:
-        * rendering/InlineFlowBox.h:
-        * rendering/RenderLayer.h:
+        * dom/Document.h: Chnaged HitTestRequest to a class from a struct.
+        * page/EventHandler.h: Ditto.
+        * rendering/EllipsisBox.h: Ditto.
+        * rendering/InlineBox.h: Ditto.
+        * rendering/InlineFlowBox.h: Ditto.
+        * rendering/RenderLayer.h: Ditto.
 
 2009-02-02  Darin Adler  <darin@apple.com>
 
index 6c46ae4..22154ce 100644 (file)
@@ -77,7 +77,7 @@ static String cssPropertyName(const Identifier& propertyName, bool* hadPixelOrPo
         return String();
 
     Vector<UChar> name;
-    name.reserveCapacity(length);
+    name.reserveInitialCapacity(length);
 
     unsigned i = 0;
 
index 2e2064a..6a436a1 100644 (file)
@@ -81,7 +81,7 @@ CSSMutableStyleDeclaration::CSSMutableStyleDeclaration(CSSRule* parent, const CS
     , m_iteratorCount(0)
 #endif
 {
-    m_properties.reserveCapacity(numProperties);
+    m_properties.reserveInitialCapacity(numProperties);
     for (int i = 0; i < numProperties; ++i) {
         ASSERT(properties[i]);
         m_properties.append(*properties[i]);
@@ -702,7 +702,7 @@ void CSSMutableStyleDeclaration::removePropertiesInSet(const int* set, unsigned
         toRemove.add(set[i]);
     
     Vector<CSSProperty> newProperties;
-    newProperties.reserveCapacity(m_properties.size());
+    newProperties.reserveInitialCapacity(m_properties.size());
     
     unsigned size = m_properties.size();
     for (unsigned n = 0; n < size; ++n) {
index 43fb70b..4bf6005 100644 (file)
@@ -768,7 +768,7 @@ String CSSPrimitiveValue::cssText() const
 
             Rect* rectVal = getRectValue();
             Vector<UChar> result;
-            result.reserveCapacity(32);
+            result.reserveInitialCapacity(32);
             append(result, rectParen);
 
             append(result, rectVal->top()->cssText());
@@ -797,7 +797,7 @@ String CSSPrimitiveValue::cssText() const
             Color color(rgbColor);
 
             Vector<UChar> result;
-            result.reserveCapacity(32);
+            result.reserveInitialCapacity(32);
             if (color.hasAlpha())
                 append(result, rgbaParen);
             else
index b840e07..a35f817 100644 (file)
@@ -142,7 +142,7 @@ void CSSStyleDeclaration::diff(CSSMutableStyleDeclaration* style) const
 PassRefPtr<CSSMutableStyleDeclaration> CSSStyleDeclaration::copyPropertiesInSet(const int* set, unsigned length) const
 {
     Vector<CSSProperty> list;
-    list.reserveCapacity(length);
+    list.reserveInitialCapacity(length);
     unsigned variableDependentValueCount = 0;
     for (unsigned i = 0; i < length; i++) {
         RefPtr<CSSValue> value = getPropertyCSSValue(set[i]);
index 3216fb0..b69d9ce 100644 (file)
@@ -753,7 +753,7 @@ void CSSStyleSelector::sortMatchedRules(unsigned start, unsigned end)
     // We have to merge sort.  Ensure our merge buffer is big enough to hold
     // all the items.
     Vector<CSSRuleData*> rulesMergeBuffer;
-    rulesMergeBuffer.reserveCapacity(end - start); 
+    rulesMergeBuffer.reserveInitialCapacity(end - start); 
 
     unsigned i1 = start;
     unsigned i2 = mid;
index b122c60..341a8d5 100644 (file)
@@ -3905,7 +3905,7 @@ void Document::finishedParsing()
 Vector<String> Document::formElementsState() const
 {
     Vector<String> stateVector;
-    stateVector.reserveCapacity(m_formElementsWithState.size() * 3);
+    stateVector.reserveInitialCapacity(m_formElementsWithState.size() * 3);
     typedef ListHashSet<FormControlElementWithState*>::const_iterator Iterator;
     Iterator end = m_formElementsWithState.end();
     for (Iterator it = m_formElementsWithState.begin(); it != end; ++it) {
index de634e0..61628e4 100644 (file)
@@ -52,7 +52,7 @@ public:
     Attribute* getAttributeItem(const QualifiedName&) const;
 
     void shrinkToLength() { m_attributes.shrinkCapacity(length()); }
-    void reserveCapacity(unsigned capacity) { m_attributes.reserveCapacity(capacity); }
+    void reserveInitialCapacity(unsigned capacity) { m_attributes.reserveInitialCapacity(capacity); }
 
     // used during parsing: only inserts if not already there
     // no error checking!
index 43496be..c2aa75d 100644 (file)
@@ -1059,7 +1059,7 @@ void CharacterIterator::advance(int count)
 String CharacterIterator::string(int numChars)
 {
     Vector<UChar> result;
-    result.reserveCapacity(numChars);
+    result.reserveInitialCapacity(numChars);
     while (numChars > 0 && !atEnd()) {
         int runSize = min(numChars, length());
         result.append(characters(), runSize);
@@ -1227,7 +1227,7 @@ inline SearchBuffer::SearchBuffer(const String& target, bool isCaseSensitive)
     ASSERT(!m_target.isEmpty());
 
     size_t targetLength = target.length();
-    m_buffer.reserveCapacity(max(targetLength * 8, minimumSearchBufferSize));
+    m_buffer.reserveInitialCapacity(max(targetLength * 8, minimumSearchBufferSize));
     m_overlap = m_buffer.capacity() / 4;
 
     // Grab the single global searcher.
@@ -1544,7 +1544,7 @@ UChar* plainTextToMallocAllocatedBuffer(const Range* r, unsigned& bufferLength,
     typedef pair<UChar*, unsigned> TextSegment;
     Vector<TextSegment>* textSegments = 0;
     Vector<UChar> textBuffer;
-    textBuffer.reserveCapacity(cMaxSegmentSize);
+    textBuffer.reserveInitialCapacity(cMaxSegmentSize);
     for (TextIterator it(r); !it.atEnd(); it.advance()) {
         if (textBuffer.size() && textBuffer.size() + it.length() > cMaxSegmentSize) {
             UChar* newSegmentBuffer = static_cast<UChar*>(malloc(textBuffer.size() * sizeof(UChar)));
index 1352457..4d5648c 100644 (file)
@@ -690,7 +690,7 @@ static String joinMarkups(const Vector<String>& preMarkups, const Vector<String>
         length += postMarkups[i].length();
 
     Vector<UChar> result;
-    result.reserveCapacity(length);
+    result.reserveInitialCapacity(length);
 
     for (size_t i = preCount; i > 0; --i)
         append(result, preMarkups[i - 1]);
index 9042980..dd76d34 100644 (file)
@@ -125,7 +125,7 @@ inline HistoryItem::HistoryItem(const HistoryItem& item)
         m_formData = item.m_formData->copy();
         
     unsigned size = item.m_subItems.size();
-    m_subItems.reserveCapacity(size);
+    m_subItems.reserveInitialCapacity(size);
     for (unsigned i = 0; i < size; ++i)
         m_subItems.append(item.m_subItems[i]->copy());
 
index a0906ff..533a8bb 100644 (file)
@@ -140,7 +140,7 @@ inline void Token::addAttribute(AtomicString& attrName, const AtomicString& attr
         RefPtr<MappedAttribute> a = MappedAttribute::create(attrName, attributeValue);
         if (!attrs) {
             attrs = NamedMappedAttrMap::create();
-            attrs->reserveCapacity(10);
+            attrs->reserveInitialCapacity(10);
         }
         attrs->insertAttribute(a.release(), viewSourceMode);
     }
index 5bc4420..90d2930 100644 (file)
@@ -132,7 +132,7 @@ PassRefPtr<DOMStringList> DOMApplicationCache::items()
     Vector<String> result;
     if (ApplicationCache* cache = associatedCache()) {
         unsigned numEntries = cache->numDynamicEntries();
-        result.reserveCapacity(numEntries);
+        result.reserveInitialCapacity(numEntries);
         for (unsigned i = 0; i < numEntries; ++i)
             result.append(cache->dynamicEntry(i));
     }
index f735c77..ae0150b 100644 (file)
@@ -221,7 +221,7 @@ String SecurityOrigin::toString() const
         return String("file://");
 
     Vector<UChar> result;
-    result.reserveCapacity(m_protocol.length() + m_host.length() + 10);
+    result.reserveInitialCapacity(m_protocol.length() + m_host.length() + 10);
     append(result, m_protocol);
     append(result, "://");
     append(result, m_host);
index 2daa3f7..f0b05f8 100644 (file)
@@ -873,7 +873,7 @@ static WebCoreTextMarkerRange* textMarkerRangeFromVisiblePositions(VisiblePositi
 static void convertToVector(NSArray* array, AccessibilityObject::AccessibilityChildrenVector& vector)
 {
     unsigned length = [array count];
-    vector.reserveCapacity(length);
+    vector.reserveInitialCapacity(length);
     for (unsigned i = 0; i < length; ++i) {
         AccessibilityObject* obj = [[array objectAtIndex:i] accessibilityObject];
         if (obj)
index 2d219be..6703dbe 100644 (file)
@@ -304,7 +304,7 @@ void FontCache::purgeInactiveFontData(int count)
     }
 
     Vector<FontPlatformDataCacheKey> keysToRemove;
-    keysToRemove.reserveCapacity(gFontPlatformDataCache->size());
+    keysToRemove.reserveInitialCapacity(gFontPlatformDataCache->size());
     FontPlatformDataCache::iterator platformDataEnd = gFontPlatformDataCache->end();
     for (FontPlatformDataCache::iterator platformData = gFontPlatformDataCache->begin(); platformData != platformDataEnd; ++platformData) {
         if (platformData->second && !gFontDataCache->contains(*platformData->second))
@@ -424,7 +424,7 @@ void FontCache::invalidate()
 
     Vector<RefPtr<FontSelector> > clients;
     size_t numClients = gClients->size();
-    clients.reserveCapacity(numClients);
+    clients.reserveInitialCapacity(numClients);
     HashSet<FontSelector*>::iterator end = gClients->end();
     for (HashSet<FontSelector*>::iterator it = gClients->begin(); it != end; ++it)
         clients.append(*it);
index 3cac168..229730a 100644 (file)
@@ -98,7 +98,7 @@ PassRefPtr<FormData> FormData::deepCopy() const
     formData->m_alwaysStream = m_alwaysStream;
 
     size_t n = m_elements.size();
-    formData->m_elements.reserveCapacity(n);
+    formData->m_elements.reserveInitialCapacity(n);
     for (size_t i = 0; i < n; ++i) {
         const FormDataElement& e = m_elements[i];
         switch (e.m_type) {
index aa9c5fa..ff470a0 100644 (file)
@@ -41,7 +41,7 @@ namespace WebCore {
 auto_ptr<CrossThreadHTTPHeaderMapData> HTTPHeaderMap::copyData() const
 {
     auto_ptr<CrossThreadHTTPHeaderMapData> data(new CrossThreadHTTPHeaderMapData());
-    data->reserveCapacity(size());
+    data->reserveInitialCapacity(size());
 
     HTTPHeaderMap::const_iterator end_it = end();
     for (HTTPHeaderMap::const_iterator it = begin(); it != end_it; ++it) {
index 15469a0..8d4f457 100644 (file)
@@ -76,7 +76,7 @@ auto_ptr<CrossThreadResourceRequestData> ResourceRequestBase::copyData() const
     data->m_httpMethod = httpMethod().copy();
     data->m_httpHeaders.adopt(httpHeaderFields().copyData());
 
-    data->m_responseContentDispositionEncodingFallbackArray.reserveCapacity(m_responseContentDispositionEncodingFallbackArray.size());
+    data->m_responseContentDispositionEncodingFallbackArray.reserveInitialCapacity(m_responseContentDispositionEncodingFallbackArray.size());
     size_t encodingArraySize = m_responseContentDispositionEncodingFallbackArray.size();
     for (size_t index = 0; index < encodingArraySize; ++index) {
         data->m_responseContentDispositionEncodingFallbackArray.append(m_responseContentDispositionEncodingFallbackArray[index].copy());
index b618949..94fdb25 100644 (file)
@@ -204,7 +204,7 @@ static void* formCreate(CFReadStreamRef stream, void* context)
 
     // Append in reverse order since we remove elements from the end.
     size_t size = formData->elements().size();
-    newInfo->remainingElements.reserveCapacity(size);
+    newInfo->remainingElements.reserveInitialCapacity(size);
     for (size_t i = 0; i < size; ++i)
         newInfo->remainingElements.append(formData->elements()[size - i - 1]);
 
index e29c096..ba9423e 100644 (file)
@@ -162,7 +162,7 @@ void NodeSet::sort() const
     
     // It is not possible to just assign the result to m_nodes, because some nodes may get dereferenced and destroyed.
     Vector<RefPtr<Node> > sortedNodes;
-    sortedNodes.reserveCapacity(nodeCount);
+    sortedNodes.reserveInitialCapacity(nodeCount);
     for (unsigned i = 0; i < nodeCount; ++i)
         sortedNodes.append(parentMatrix[i][0]);