diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-07-22 13:32:47 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-08-30 13:18:28 +0200 |
commit | 540774d7dfe2a309fca181d9e54e14ba87069bbd (patch) | |
tree | 68097163a21e37c89791973aaee15315e5e06a3c /src/declarative/qml/ftw/qhashedstring_p.h | |
parent | 0b03d57a3ffcdb0514061242a6d7423faba30b92 (diff) |
Optimize default property resolution in compiler
Change-Id: I90b677a190c0c59ba681a7643a9b13cfb938d5a1
Reviewed-on: http://codereview.qt.nokia.com/3769
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'src/declarative/qml/ftw/qhashedstring_p.h')
-rw-r--r-- | src/declarative/qml/ftw/qhashedstring_p.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/declarative/qml/ftw/qhashedstring_p.h b/src/declarative/qml/ftw/qhashedstring_p.h index c04e504560..f6c7f20d3a 100644 --- a/src/declarative/qml/ftw/qhashedstring_p.h +++ b/src/declarative/qml/ftw/qhashedstring_p.h @@ -109,6 +109,7 @@ private: v8::Handle<v8::String> m_string; }; +class QHashedCStringRef; class Q_AUTOTEST_EXPORT QHashedStringRef { public: @@ -124,9 +125,11 @@ public: inline bool operator==(const QString &string) const; inline bool operator==(const QHashedString &string) const; inline bool operator==(const QHashedStringRef &string) const; + inline bool operator==(const QHashedCStringRef &string) const; inline bool operator!=(const QString &string) const; inline bool operator!=(const QHashedString &string) const; inline bool operator!=(const QHashedStringRef &string) const; + inline bool operator!=(const QHashedCStringRef &string) const; inline quint32 hash() const; @@ -169,7 +172,14 @@ public: inline const char *constData() const; inline int length() const; + + QString toUtf16() const; + inline int utf16length() const; + inline void writeUtf16(QChar *) const; + inline void writeUtf16(uint16_t *) const; private: + friend class QHashedStringRef; + void computeHash() const; const char *m_data; @@ -972,6 +982,13 @@ bool QHashedStringRef::operator==(const QHashedStringRef &string) const QHashedString::compare(string.m_data, m_data, m_length); } +bool QHashedStringRef::operator==(const QHashedCStringRef &string) const +{ + return m_length == string.m_length && + (m_hash == string.m_hash || !m_hash || !string.m_hash) && + QHashedString::compare(m_data, string.m_data, m_length); +} + bool QHashedStringRef::operator!=(const QString &string) const { return m_length != string.length() || @@ -992,6 +1009,13 @@ bool QHashedStringRef::operator!=(const QHashedStringRef &string) const QHashedString::compare(string.m_data, m_data, m_length); } +bool QHashedStringRef::operator!=(const QHashedCStringRef &string) const +{ + return m_length != string.m_length || + (m_hash != string.m_hash && m_hash && string.m_hash) || + QHashedString::compare(m_data, string.m_data, m_length); +} + const QChar &QHashedStringRef::at(int index) const { Q_ASSERT(index < m_length); @@ -1068,6 +1092,24 @@ int QHashedCStringRef::length() const return m_length; } +int QHashedCStringRef::utf16length() const +{ + return m_length; +} + +void QHashedCStringRef::writeUtf16(QChar *output) const +{ + writeUtf16((uint16_t *)output); +} + +void QHashedCStringRef::writeUtf16(uint16_t *output) const +{ + int l = m_length; + const char *d = m_data; + while (l--) + *output++ = *d++; +} + bool QHashedString::compare(const QChar *lhs, const char *rhs, int length) { Q_ASSERT(lhs && rhs); |