aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/ftw
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2012-05-16 17:49:32 +1000
committerQt by Nokia <qt-info@nokia.com>2012-05-17 13:42:27 +0200
commit8017cf63505f7ed477c658634ec882a12d3b3ddc (patch)
tree28d023fe7e8a2b2392c564a37ef7b891d2bb41b8 /src/qml/qml/ftw
parentc556eecc25e24d6ee4f5c9965193a588c93b95fc (diff)
Optimize type resolution
Faster qmlType() and resolveType() lookup. Change-Id: I096439f23bf6071e8bfdf0cda366cc71e00293ba Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
Diffstat (limited to 'src/qml/qml/ftw')
-rw-r--r--src/qml/qml/ftw/qhashedstring.cpp21
-rw-r--r--src/qml/qml/ftw/qhashedstring_p.h1
2 files changed, 22 insertions, 0 deletions
diff --git a/src/qml/qml/ftw/qhashedstring.cpp b/src/qml/qml/ftw/qhashedstring.cpp
index 1f09d50ed3..2dc717b488 100644
--- a/src/qml/qml/ftw/qhashedstring.cpp
+++ b/src/qml/qml/ftw/qhashedstring.cpp
@@ -443,6 +443,27 @@ bool QHashedStringRef::startsWith(const QString &s) const
QHashedString::compare(s.constData(), m_data, s.length());
}
+static int findChar(const QChar *str, int len, QChar ch, int from)
+{
+ const ushort *s = (const ushort *)str;
+ ushort c = ch.unicode();
+ if (from < 0)
+ from = qMax(from + len, 0);
+ if (from < len) {
+ const ushort *n = s + from - 1;
+ const ushort *e = s + len;
+ while (++n != e)
+ if (*n == c)
+ return n - s;
+ }
+ return -1;
+}
+
+int QHashedStringRef::indexOf(const QChar &c, int from) const
+{
+ return findChar(m_data, m_length, c, from);
+}
+
QString QHashedStringRef::toString() const
{
if (m_length == 0)
diff --git a/src/qml/qml/ftw/qhashedstring_p.h b/src/qml/qml/ftw/qhashedstring_p.h
index f058f21e98..f8099d508b 100644
--- a/src/qml/qml/ftw/qhashedstring_p.h
+++ b/src/qml/qml/ftw/qhashedstring_p.h
@@ -148,6 +148,7 @@ public:
inline const QChar *constData() const;
bool startsWith(const QString &) const;
bool endsWith(const QString &) const;
+ int indexOf(const QChar &, int from=0) const;
QHashedStringRef mid(int, int) const;
inline bool isEmpty() const;