Changeset 147887 in webkit


Ignore:
Timestamp:
Apr 7, 2013 5:43:46 PM (11 years ago)
Author:
benjamin@webkit.org
Message:

Use Vector::reserveInitialCapacity() when possible in JavaScriptCore runtime
https://bugs.webkit.org/show_bug.cgi?id=114111

Reviewed by Andreas Kling.

Almost all the code was already using Vector::reserveInitialCapacity()
and Vector::uncheckedAppend(). Fix the remaining parts.

  • runtime/ArgList.h:

(MarkedArgumentBuffer): The type VectorType is unused.

  • runtime/ArrayPrototype.cpp:

(JSC::arrayProtoFuncSort):
Move the variable closer to where it is needed.

  • runtime/JSArray.cpp:

(JSC::JSArray::setLengthWithArrayStorage):

  • runtime/JSObject.cpp:

(JSC::JSObject::getOwnPropertyNames):

Location:
trunk/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r147879 r147887  
     12013-04-07  Benjamin Poulain  <benjamin@webkit.org>
     2
     3        Use Vector::reserveInitialCapacity() when possible in JavaScriptCore runtime
     4        https://bugs.webkit.org/show_bug.cgi?id=114111
     5
     6        Reviewed by Andreas Kling.
     7
     8        Almost all the code was already using Vector::reserveInitialCapacity()
     9        and Vector::uncheckedAppend(). Fix the remaining parts.
     10
     11        * runtime/ArgList.h:
     12        (MarkedArgumentBuffer): The type VectorType is unused.
     13
     14        * runtime/ArrayPrototype.cpp:
     15        (JSC::arrayProtoFuncSort):
     16        Move the variable closer to where it is needed.
     17
     18        * runtime/JSArray.cpp:
     19        (JSC::JSArray::setLengthWithArrayStorage):
     20        * runtime/JSObject.cpp:
     21        (JSC::JSObject::getOwnPropertyNames):
     22
    1232013-04-07  Patrick Gansterer  <paroga@webkit.org>
    224
  • trunk/Source/JavaScriptCore/runtime/ArgList.h

    r133800 r147887  
    3939private:
    4040    static const size_t inlineCapacity = 8;
    41     typedef Vector<Register, inlineCapacity> VectorType;
    4241    typedef HashSet<MarkedArgumentBuffer*> ListSet;
    4342
  • trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp

    r145628 r147887  
    739739        return performSlowSort(exec, thisObj, length, function, callData, callType) ? JSValue::encode(thisObj) : JSValue::encode(jsUndefined());
    740740   
    741     Vector<uint32_t> keys;
    742    
    743741    JSGlobalObject* globalObject = JSGlobalObject::create(
    744742        exec->globalData(), JSGlobalObject::createStructure(exec->globalData(), jsNull()));
     
    751749    if (exec->hadException())
    752750        return JSValue::encode(jsUndefined());
    753    
     751
     752    Vector<uint32_t> keys;
    754753    for (size_t i = 0; i < nameArray.size(); ++i) {
    755754        PropertyName name = nameArray[i];
  • trunk/Source/JavaScriptCore/runtime/JSArray.cpp

    r141154 r147887  
    351351            // Copy any keys we might be interested in into a vector.
    352352            Vector<unsigned> keys;
    353             keys.reserveCapacity(min(map->size(), static_cast<size_t>(length - newLength)));
     353            keys.reserveInitialCapacity(min(map->size(), static_cast<size_t>(length - newLength)));
    354354            SparseArrayValueMap::const_iterator end = map->end();
    355355            for (SparseArrayValueMap::const_iterator it = map->begin(); it != end; ++it) {
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r147570 r147887  
    15081508        if (SparseArrayValueMap* map = storage->m_sparseMap.get()) {
    15091509            Vector<unsigned> keys;
    1510             keys.reserveCapacity(map->size());
     1510            keys.reserveInitialCapacity(map->size());
    15111511           
    15121512            SparseArrayValueMap::const_iterator end = map->end();
    15131513            for (SparseArrayValueMap::const_iterator it = map->begin(); it != end; ++it) {
    15141514                if (mode == IncludeDontEnumProperties || !(it->value.attributes & DontEnum))
    1515                     keys.append(static_cast<unsigned>(it->key));
     1515                    keys.uncheckedAppend(static_cast<unsigned>(it->key));
    15161516            }
    15171517           
Note: See TracChangeset for help on using the changeset viewer.