aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4objectproto.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-10-13 22:08:59 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-14 21:59:56 +0200
commit668eca2b9343cf5d79dc1faa6c251595e2e84918 (patch)
treebae99ec4065b0e20ba3bbf2fab89434d43d12f07 /src/qml/jsruntime/qv4objectproto.cpp
parent669e6b434f015982d2e5e9f48ef72d8e8eebb0ac (diff)
Avoid creating array attributes if possible
Holes in arrays should be represented by an empty value, not by creating/setting array attributes. Reason is that the creation is irreversable, and slows down execution. This speeds up crypto.js by 10% Change-Id: I2e5472575479a5f2dbe53f59ecb8ed3aeab1be7a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4objectproto.cpp')
-rw-r--r--src/qml/jsruntime/qv4objectproto.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp
index 21cbc8d7fd..7cfda589e5 100644
--- a/src/qml/jsruntime/qv4objectproto.cpp
+++ b/src/qml/jsruntime/qv4objectproto.cpp
@@ -259,7 +259,7 @@ ReturnedValue ObjectPrototype::method_seal(SimpleCallContext *ctx)
o->ensureArrayAttributes();
for (uint i = 0; i < o->arrayDataLen; ++i) {
- if (!o->arrayAttributes[i].isGeneric())
+ if (!(o->arrayAttributes[i].isGeneric() || o->arrayData[i].value.isEmpty()))
o->arrayAttributes[i].setConfigurable(false);
}
@@ -279,7 +279,7 @@ ReturnedValue ObjectPrototype::method_freeze(SimpleCallContext *ctx)
o->ensureArrayAttributes();
for (uint i = 0; i < o->arrayDataLen; ++i) {
- if (!o->arrayAttributes[i].isGeneric())
+ if (!(o->arrayAttributes[i].isGeneric() || o->arrayData[i].value.isEmpty()))
o->arrayAttributes[i].setConfigurable(false);
if (o->arrayAttributes[i].isData())
o->arrayAttributes[i].setWritable(false);
@@ -318,7 +318,7 @@ ReturnedValue ObjectPrototype::method_isSealed(SimpleCallContext *ctx)
return Encode(false);
for (uint i = 0; i < o->arrayDataLen; ++i) {
- if (!o->arrayAttributes[i].isGeneric())
+ if (!(o->arrayAttributes[i].isGeneric() || o->arrayData[i].value.isEmpty()))
if (o->arrayAttributes[i].isConfigurable())
return Encode(false);
}
@@ -346,7 +346,7 @@ ReturnedValue ObjectPrototype::method_isFrozen(SimpleCallContext *ctx)
return Encode(false);
for (uint i = 0; i < o->arrayDataLen; ++i) {
- if (!o->arrayAttributes[i].isGeneric())
+ if (!(o->arrayAttributes[i].isGeneric() || o->arrayData[i].value.isEmpty()))
if (o->arrayAttributes[i].isConfigurable() || o->arrayAttributes[i].isWritable())
return Encode(false);
}