Changeset 40501 in webkit for trunk/JavaScriptCore/wtf/Vector.h


Ignore:
Timestamp:
Feb 2, 2009, 4:27:14 PM (16 years ago)
Author:
Darin Adler
Message:

JavaScriptCore:

2009-02-02 Darin Adler <Darin Adler>

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 Adler>

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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/Vector.h

    r38875 r40501  
    504504        void resize(size_t size);
    505505        void reserveCapacity(size_t newCapacity);
     506        void reserveInitialCapacity(size_t initialCapacity);
    506507        void shrinkCapacity(size_t newCapacity);
    507508        void shrinkToFit() { shrinkCapacity(size()); }
     
    731732            TypeOperations::move(oldBuffer, oldEnd, begin());
    732733        m_buffer.deallocateBuffer(oldBuffer);
     734    }
     735   
     736    template<typename T, size_t inlineCapacity>
     737    inline void Vector<T, inlineCapacity>::reserveInitialCapacity(size_t initialCapacity)
     738    {
     739        ASSERT(!m_size);
     740        ASSERT(capacity() == inlineCapacity);
     741        if (initialCapacity > inlineCapacity)
     742            m_buffer.allocateBuffer(initialCapacity);
    733743    }
    734744   
Note: See TracChangeset for help on using the changeset viewer.