зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1368454 - Optimize js::CreateIterResultObject by using ObjectGroup::newPlainObject instead of manually creating the object and defining its properties. r=jandem
This should improve performance of creating the object and TI for code using iteration result objects. MozReview-Commit-ID: 2QGqFs7V3uH
This commit is contained in:
Родитель
deb7d25aa4
Коммит
7f4b13656d
|
@ -1045,24 +1045,19 @@ js::CreateIterResultObject(JSContext* cx, HandleValue value, bool done)
|
|||
{
|
||||
// Step 1 (implicit).
|
||||
|
||||
// Step 2.
|
||||
RootedObject resultObj(cx, NewBuiltinClassInstance<PlainObject>(cx));
|
||||
if (!resultObj)
|
||||
Rooted<IdValueVector> props(cx, IdValueVector(cx));
|
||||
if (!props.reserve(2))
|
||||
return nullptr;
|
||||
|
||||
// Step 3.
|
||||
if (!DefineProperty(cx, resultObj, cx->names().value, value))
|
||||
return nullptr;
|
||||
// Step 2 (reordered).
|
||||
props.infallibleAppend(IdValuePair(NameToId(cx->names().value), value));
|
||||
|
||||
// Step 4.
|
||||
if (!DefineProperty(cx, resultObj, cx->names().done,
|
||||
done ? TrueHandleValue : FalseHandleValue))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
// Step 3 (reordered).
|
||||
props.infallibleAppend(IdValuePair(NameToId(cx->names().done),
|
||||
done ? TrueHandleValue : FalseHandleValue));
|
||||
|
||||
// Step 5.
|
||||
return resultObj;
|
||||
// Steps 1, 5.
|
||||
return ObjectGroup::newPlainObject(cx, props.begin(), props.length(), GenericObject);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
Загрузка…
Ссылка в новой задаче