Ignore:
Timestamp:
Sep 15, 2008, 12:27:14 AM (17 years ago)
Author:
[email protected]
Message:

2008-09-15 Sam Weinig <[email protected]>

Reviewed by Maciej Stachowiak.

Patch for https://bugs.webkit.org/show_bug.cgi?id=20849
Cache property names for getEnumerablePropertyNames in the StructureID.

~0.5% speedup on Sunspider overall (9.7% speedup on string-fasta). ~1% speedup
on the v8 test suite.

  • kjs/JSObject.cpp: (JSC::JSObject::getPropertyNames):
  • kjs/PropertyMap.cpp: (JSC::PropertyMap::getEnumerablePropertyNames):
  • kjs/PropertyMap.h:
  • kjs/StructureID.cpp: (JSC::StructureID::StructureID): (JSC::StructureID::getEnumerablePropertyNames):
  • kjs/StructureID.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/PropertyMap.cpp

    r36325 r36429  
    2424#include "JSObject.h"
    2525#include "protect.h"
    26 #include "PropertyNameArray.h"
    2726#include <algorithm>
    2827#include <wtf/Assertions.h>
     
    474473}
    475474
    476 void PropertyMap::getEnumerablePropertyNames(PropertyNameArray& propertyNames) const
     475void PropertyMap::getEnumerablePropertyNames(Vector<UString::Rep*>& propertyNames) const
    477476{
    478477    if (!m_table)
     
    493492            }
    494493        }
    495         if (!propertyNames.size()) {
    496             for (int k = 0; k < i; ++k)
    497                 propertyNames.addKnownUnique(a[k]->key);
    498         } else {
    499             for (int k = 0; k < i; ++k)
    500                 propertyNames.add(a[k]->key);
    501         }
     494        propertyNames.reserveCapacity(i);
     495        for (int k = 0; k < i; ++k)
     496            propertyNames.append(a[k]->key);
    502497        return;
    503498    }
     
    518513
    519514    // Put the keys of the sorted entries into the list.
    520     for (Entry** q = sortedEnumerables.data(); q != p; ++q)
    521         propertyNames.add(q[0]->key);
     515    propertyNames.reserveCapacity(sortedEnumerables.size());
     516    for (size_t i = 0; i < sortedEnumerables.size(); ++i)
     517        propertyNames.append(sortedEnumerables[i]->key);
    522518}
    523519
Note: See TracChangeset for help on using the changeset viewer.