diff options
Diffstat (limited to 'src/qml/qml/ftw')
-rw-r--r-- | src/qml/qml/ftw/qhashedstring.cpp | 21 | ||||
-rw-r--r-- | src/qml/qml/ftw/qhashedstring_p.h | 1 |
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; |