aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/v8/qhashedstring_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml/v8/qhashedstring_p.h')
-rw-r--r--src/declarative/qml/v8/qhashedstring_p.h21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/declarative/qml/v8/qhashedstring_p.h b/src/declarative/qml/v8/qhashedstring_p.h
index ed00aea132..0dd111e189 100644
--- a/src/declarative/qml/v8/qhashedstring_p.h
+++ b/src/declarative/qml/v8/qhashedstring_p.h
@@ -137,11 +137,27 @@ class QStringHashNode
{
public:
QStringHashNode(const QHashedString &key)
- : nlist(0), next(0), key(key) {}
+ : nlist(0), next(0), key(key) {
+ if (isAscii()) ascii = key.toAscii();
+ }
QStringHashNode *nlist;
QStringHashNode *next;
QHashedString key;
+ QByteArray ascii;
+
+ inline bool equals(v8::Handle<v8::String> string) {
+ return !ascii.isEmpty() && string->Equals((char*)ascii.constData(), ascii.length()) ||
+ ascii.isEmpty() && string->Equals((uint16_t*)key.constData(), key.length());
+ }
+private:
+ bool isAscii() const {
+ for (int ii = 0; ii < key.length(); ++ii) {
+ if (key.at(ii) > 127)
+ return false;
+ }
+ return true;
+ }
};
struct QStringHashData
@@ -369,8 +385,7 @@ typename QStringHash<T>::Node *QStringHash<T>::findNode(const QHashedV8String &s
quint32 hash = string.hash();
node = data.buckets[hash % data.numBuckets];
int length = string.length();
- while (node && (length != node->key.length() || hash != node->key.hash() ||
- !string.string()->Equals((uint16_t*)node->key.constData(), length)))
+ while (node && (length != node->key.length() || hash != node->key.hash() || !node->equals(string.string())))
node = node->next;
}