aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-11-21 14:25:49 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-04 09:45:40 +0100
commit81d55c6ef3b8faf6ca7bfcc7f9e212e382c2689f (patch)
treeabf9cb2870c4475ad20d562ab0017c94568d4a14 /src/qml/jsruntime
parent8831e02402fa0b2a3cdfdc017bcbb10bf000995e (diff)
Add a static toArrayIndex() method to QV4::String
This avoids a hack in QV4::Codegen where we created a V4::String on the stack to convert to an array index. Change-Id: I9a88d45817bbcde52a4037a52fbae299b8c9cb1a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4string.cpp12
-rw-r--r--src/qml/jsruntime/qv4string_p.h2
2 files changed, 11 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp
index 7ac83ced02..37508e79f6 100644
--- a/src/qml/jsruntime/qv4string.cpp
+++ b/src/qml/jsruntime/qv4string.cpp
@@ -359,7 +359,7 @@ void String::createHashValue() const
// array indices get their number as hash value
bool ok;
- stringHash = toArrayIndex(ch, end, &ok);
+ stringHash = ::toArrayIndex(ch, end, &ok);
if (ok) {
subtype = (stringHash == UINT_MAX) ? StringType_UInt : StringType_ArrayIndex;
return;
@@ -381,7 +381,7 @@ uint String::createHashValue(const QChar *ch, int length)
// array indices get their number as hash value
bool ok;
- uint stringHash = toArrayIndex(ch, end, &ok);
+ uint stringHash = ::toArrayIndex(ch, end, &ok);
if (ok)
return stringHash;
@@ -400,7 +400,7 @@ uint String::createHashValue(const char *ch, int length)
// array indices get their number as hash value
bool ok;
- uint stringHash = toArrayIndex(ch, end, &ok);
+ uint stringHash = ::toArrayIndex(ch, end, &ok);
if (ok)
return stringHash;
@@ -414,3 +414,9 @@ uint String::createHashValue(const char *ch, int length)
return h;
}
+
+uint String::toArrayIndex(const QString &str)
+{
+ bool ok;
+ return ::toArrayIndex(str.constData(), str.constData() + str.length(), &ok);
+}
diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h
index bb6f1d2279..545e08de78 100644
--- a/src/qml/jsruntime/qv4string_p.h
+++ b/src/qml/jsruntime/qv4string_p.h
@@ -140,6 +140,8 @@ struct Q_QML_EXPORT String : public Managed {
return len;
}
+ static uint toArrayIndex(const QString &str);
+
union {
mutable QStringData *_text;
mutable String *left;