diff options
author | Erik Verbruggen <erik.verbruggen@theqtcompany.com> | 2016-04-21 14:08:06 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-05-12 14:08:37 +0000 |
commit | a7b383ab989e74ef552c2ef9c38377e065f1ab0e (patch) | |
tree | a278dba709e1133e805d8d64cf3facb5d716ea89 /src/qml/jsruntime/qv4identifiertable.cpp | |
parent | 32897258b4b9309cae9562a61fea280acd954aa5 (diff) |
V4: calculate the hash only once when inserting a string.
Reduces the number of instructions of IdentifierTable::identifier by ~15%.
Change-Id: I5a234fa96a6ee3e7202150ded512d1be0b36560d
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/jsruntime/qv4identifiertable.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4identifiertable.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4identifiertable.cpp b/src/qml/jsruntime/qv4identifiertable.cpp index 5adb17b4ea..3def6defbf 100644 --- a/src/qml/jsruntime/qv4identifiertable.cpp +++ b/src/qml/jsruntime/qv4identifiertable.cpp @@ -118,7 +118,8 @@ void IdentifierTable::addEntry(Heap::String *str) Heap::String *IdentifierTable::insertString(const QString &s) { - uint hash = String::createHashValue(s.constData(), s.length()); + uint subtype; + uint hash = String::createHashValue(s.constData(), s.length(), &subtype); uint idx = hash % alloc; while (Heap::String *e = entries[idx]) { if (e->stringHash == hash && e->toQString() == s) @@ -128,6 +129,8 @@ Heap::String *IdentifierTable::insertString(const QString &s) } Heap::String *str = engine->newString(s); + str->stringHash = hash; + str->subtype = subtype; addEntry(str); return str; } @@ -178,7 +181,8 @@ Identifier *IdentifierTable::identifier(const QString &s) Identifier *IdentifierTable::identifier(const char *s, int len) { - uint hash = String::createHashValue(s, len); + uint subtype; + uint hash = String::createHashValue(s, len, &subtype); if (hash == UINT_MAX) return identifier(QString::fromUtf8(s, len)); @@ -192,6 +196,8 @@ Identifier *IdentifierTable::identifier(const char *s, int len) } Heap::String *str = engine->newString(QString::fromLatin1(s, len)); + str->stringHash = hash; + str->subtype = subtype; addEntry(str); return str->identifier; } |