Commit 48cefd3c authored by benjamin@webkit.org's avatar benjamin@webkit.org

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):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@147887 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 46083c5b
2013-04-07 Benjamin Poulain <benjamin@webkit.org>
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):
2013-04-07 Patrick Gansterer <paroga@webkit.org>
Remove references to Skia and V8 from CMake files
......@@ -38,7 +38,6 @@ class MarkedArgumentBuffer {
private:
static const size_t inlineCapacity = 8;
typedef Vector<Register, inlineCapacity> VectorType;
typedef HashSet<MarkedArgumentBuffer*> ListSet;
public:
......
......@@ -738,8 +738,6 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncSort(ExecState* exec)
if (length < 1000)
return performSlowSort(exec, thisObj, length, function, callData, callType) ? JSValue::encode(thisObj) : JSValue::encode(jsUndefined());
Vector<uint32_t> keys;
JSGlobalObject* globalObject = JSGlobalObject::create(
exec->globalData(), JSGlobalObject::createStructure(exec->globalData(), jsNull()));
JSArray* flatArray = constructEmptyArray(globalObject->globalExec(), 0);
......@@ -750,7 +748,8 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncSort(ExecState* exec)
thisObj->methodTable()->getPropertyNames(thisObj, exec, nameArray, IncludeDontEnumProperties);
if (exec->hadException())
return JSValue::encode(jsUndefined());
Vector<uint32_t> keys;
for (size_t i = 0; i < nameArray.size(); ++i) {
PropertyName name = nameArray[i];
uint32_t index = name.asIndex();
......
......@@ -350,7 +350,7 @@ bool JSArray::setLengthWithArrayStorage(ExecState* exec, unsigned newLength, boo
if (newLength < length) {
// Copy any keys we might be interested in into a vector.
Vector<unsigned> keys;
keys.reserveCapacity(min(map->size(), static_cast<size_t>(length - newLength)));
keys.reserveInitialCapacity(min(map->size(), static_cast<size_t>(length - newLength)));
SparseArrayValueMap::const_iterator end = map->end();
for (SparseArrayValueMap::const_iterator it = map->begin(); it != end; ++it) {
unsigned index = static_cast<unsigned>(it->key);
......
......@@ -1507,12 +1507,12 @@ void JSObject::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNa
if (SparseArrayValueMap* map = storage->m_sparseMap.get()) {
Vector<unsigned> keys;
keys.reserveCapacity(map->size());
keys.reserveInitialCapacity(map->size());
SparseArrayValueMap::const_iterator end = map->end();
for (SparseArrayValueMap::const_iterator it = map->begin(); it != end; ++it) {
if (mode == IncludeDontEnumProperties || !(it->value.attributes & DontEnum))
keys.append(static_cast<unsigned>(it->key));
keys.uncheckedAppend(static_cast<unsigned>(it->key));
}
std::sort(keys.begin(), keys.end());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment