Use a specialized hash function for mangled names
The hash values used for looking up built-ins now encode the string
length and the location of parentheses as six-bit values, so that we
don't need to check for these if the hash matches.
This decreases shader_translator binary size on Windows by around 10
KB.
BUG=angleproject:2267
BUG=chromium:823856
TEST=angle_unittests
Change-Id: If8c28e1c8851750633509ec6273f556e06e91cd1
Reviewed-on: https://chromium-review.googlesource.com/973243
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/ImmutableString.h b/src/compiler/translator/ImmutableString.h
index 301e91c..a9e1673 100644
--- a/src/compiler/translator/ImmutableString.h
+++ b/src/compiler/translator/ImmutableString.h
@@ -128,7 +128,10 @@
}
};
- uint32_t hash32() const;
+ // This hash encodes the opening parentheses location (if any) and name length in addition to a
+ // 20-bit hash. This way the hash is more useful for lookups. The string passed in should be at
+ // most 63 characters.
+ uint32_t mangledNameHash() const;
private:
const char *mData;