diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-03-12 08:18:01 +1000 |
---|---|---|
committer | Matthew Vogt <matthew.vogt@nokia.com> | 2012-03-12 08:35:40 +1000 |
commit | 1f52c5430144eb7ba6baa7e3954675ca0707b947 (patch) | |
tree | 22106095d5cc61c7b5625c8ff2639e1530d2c3b0 /src/qml/qml/v8 | |
parent | 616bbd1988f3b92f7d980b6c9a1278f11b712573 (diff) | |
parent | ed74ec4c40f1476c545bcaacb12fe3a607172035 (diff) |
Merge branch 'master' of git://gitorious.org/qt/qtdeclarative into api_changes
Change-Id: I578b1e2f1bb374da6194e6ba04a0fd459b2632fe
Diffstat (limited to 'src/qml/qml/v8')
-rw-r--r-- | src/qml/qml/v8/qv8sequencewrapper_p_p.h | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/qml/qml/v8/qv8sequencewrapper_p_p.h b/src/qml/qml/v8/qv8sequencewrapper_p_p.h index 9d519809fa..eebc40eeed 100644 --- a/src/qml/qml/v8/qv8sequencewrapper_p_p.h +++ b/src/qml/qml/v8/qv8sequencewrapper_p_p.h @@ -265,6 +265,7 @@ static QString convertUrlToString(QV8Engine *, const QUrl &v) static QVariant toVariant(QV8Engine *e, v8::Handle<v8::Array> array, uint32_t length, bool *succeeded) \ { \ SequenceType list; \ + list.reserve(length); \ for (uint32_t ii = 0; ii < length; ++ii) { \ list.append(ConversionFromV8fn(e, array->Get(ii))); \ } \ @@ -334,14 +335,15 @@ static QString convertUrlToString(QV8Engine *, const QUrl &v) /* according to ECMA262r3 we need to insert */ \ /* undefined values increasing length to newLength. */ \ /* We cannot, so we insert default-values instead. */ \ + QT_TRY { \ + c.reserve(newCount); \ + } QT_CATCH (std::bad_alloc &exception) { \ + generateWarning(engine, QString(QLatin1String(exception.what()) \ + + QLatin1String(" during length set"))); \ + return; /* failed; don't write back any result. */ \ + } \ while (newCount > count++) { \ - QT_TRY { \ - c.append(DefaultValue); \ - } QT_CATCH (std::bad_alloc &exception) { \ - generateWarning(engine, QString(QLatin1String(exception.what()) \ - + QLatin1String(" during length set"))); \ - return; /* failed; don't write back any result. */ \ - } \ + c.append(DefaultValue); \ } \ } else { \ /* according to ECMA262r3 we need to remove */ \ @@ -382,15 +384,16 @@ static QString convertUrlToString(QV8Engine *, const QUrl &v) /* according to ECMA262r3 we need to insert */ \ /* the value at the given index, increasing length to index+1. */ \ QT_TRY { \ - while (signedIdx > count++) { \ - c.append(DefaultValue); \ - } \ - c.append(elementValue); \ + c.reserve(signedIdx + 1); \ } QT_CATCH (std::bad_alloc &exception) { \ generateWarning(engine, QString(QLatin1String(exception.what()) \ + QLatin1String(" during indexed set"))); \ return v8::Undefined(); /* failed; don't write back any result. */ \ } \ + while (signedIdx > count++) { \ + c.append(DefaultValue); \ + } \ + c.append(elementValue); \ } \ /* write back. already checked that object is non-null, so skip that check here. */ \ if (objectType == QV8SequenceResource::Reference) \ |