aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/qml/jsruntime/qv4string.cpp21
-rw-r--r--src/qml/jsruntime/qv4string_p.h7
2 files changed, 24 insertions, 4 deletions
diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp
index 932ccf13ef..40280534c4 100644
--- a/src/qml/jsruntime/qv4string.cpp
+++ b/src/qml/jsruntime/qv4string.cpp
@@ -181,6 +181,27 @@ void Heap::String::simplifyString() const
subtype = StringType_Unknown;
}
+bool Heap::String::startsWithUpper() const
+{
+ if (subtype == StringType_AddedString)
+ return static_cast<const Heap::ComplexString *>(this)->left->startsWithUpper();
+
+ const Heap::String *str = this;
+ int offset = 0;
+ if (subtype == StringType_SubString) {
+ const ComplexString *cs = static_cast<const Heap::ComplexString *>(this);
+ if (!cs->len)
+ return false;
+ // simplification here is not ideal, but hopefully not a common case.
+ if (cs->left->subtype >= Heap::String::StringType_Complex)
+ cs->left->simplifyString();
+ str = cs->left;
+ offset = cs->from;
+ }
+ Q_ASSERT(str->subtype < Heap::String::StringType_Complex);
+ return str->text->size > offset && QChar::isUpper(str->text->data()[offset]);
+}
+
void Heap::String::append(const String *data, QChar *ch)
{
std::vector<const String *> worklist;
diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h
index 41039bca88..679cb7329c 100644
--- a/src/qml/jsruntime/qv4string_p.h
+++ b/src/qml/jsruntime/qv4string_p.h
@@ -112,6 +112,8 @@ struct Q_QML_PRIVATE_EXPORT String : Base {
return toQString() == other->toQString();
}
+ bool startsWithUpper() const;
+
mutable QStringData *text;
mutable Identifier *identifier;
mutable uint subtype;
@@ -206,10 +208,7 @@ struct Q_QML_PRIVATE_EXPORT String : public Managed {
return calculateHashValue(ch, end, subtype);
}
- bool startsWithUpper() const {
- Q_ASSERT(d()->subtype < Heap::String::StringType_Complex);
- return d()->text->size && QChar::isUpper(d()->text->data()[0]);
- }
+ bool startsWithUpper() const { return d()->startsWithUpper(); }
Identifier *identifier() const { return d()->identifier; }