summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2010-03-16 16:08:36 (GMT)
committerKent Hansen <kent.hansen@nokia.com>2010-03-16 16:10:59 (GMT)
commit92f2f1a9c74704b6c8125766c18f7c3946a50634 (patch)
tree108b6247f23b54080352c165498dc6deb99b2fe0 /src
parentd10667052db5dc2f4d1c7a7c161b040e9747897e (diff)
downloadQt-92f2f1a9c74704b6c8125766c18f7c3946a50634.zip
Qt-92f2f1a9c74704b6c8125766c18f7c3946a50634.tar.gz
Qt-92f2f1a9c74704b6c8125766c18f7c3946a50634.tar.bz2
Don't use QScriptValueIterator to iterate over an array
QScriptValueIterator will return properties that are non-enumerable, such as "length". QScriptValueIterator will return properties that are not array elements, such as "foo". QScriptValueIterator is slower than using index-based access, because the iterator builds an array of the string representation of each index, which we don't need.
Diffstat (limited to 'src')
-rw-r--r--src/declarative/qml/qdeclarativesqldatabase.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/declarative/qml/qdeclarativesqldatabase.cpp b/src/declarative/qml/qdeclarativesqldatabase.cpp
index 855d623..2d5f096 100644
--- a/src/declarative/qml/qdeclarativesqldatabase.cpp
+++ b/src/declarative/qml/qdeclarativesqldatabase.cpp
@@ -217,9 +217,15 @@ static QScriptValue qmlsqldatabase_executeSql(QScriptContext *context, QScriptEn
if (context->argumentCount() > 1) {
QScriptValue values = context->argument(1);
if (values.isObject()) {
- for (QScriptValueIterator it(values); it.hasNext();) {
- it.next();
- query.bindValue(it.name(),it.value().toVariant());
+ if (values.isArray()) {
+ int size = values.property(QLatin1String("length")).toInt32();
+ for (int i = 0; i < size; ++i)
+ query.bindValue(i, values.property(i).toVariant());
+ } else {
+ for (QScriptValueIterator it(values); it.hasNext();) {
+ it.next();
+ query.bindValue(it.name(),it.value().toVariant());
+ }
}
} else {
query.bindValue(0,values.toVariant());