diff options
Diffstat (limited to 'js/src/vm/String.h')
-rw-r--r-- | js/src/vm/String.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/js/src/vm/String.h b/js/src/vm/String.h index 4c43439cd9..5eaf9e0c2e 100644 --- a/js/src/vm/String.h +++ b/js/src/vm/String.h @@ -1131,6 +1131,20 @@ class StaticStrings static bool isStatic(JSAtom* atom); /* Return null if no static atom exists for the given (chars, length). */ + MOZ_ALWAYS_INLINE JSAtom* lookup(const char* chars, size_t length) { + // Collapse calls for |const char*| into |const Latin1Char char*| to avoid + // excess instantiations. + return lookup(reinterpret_cast<const Latin1Char*>(chars), length); + } + + template <typename CharT, + typename = typename std::enable_if<!std::is_const<CharT>::value>::type> + MOZ_ALWAYS_INLINE JSAtom* lookup(CharT* chars, size_t length) { + // Collapse the remaining |CharT*| to |const CharT*| to avoid excess + // instantiations. + return lookup(const_cast<const CharT*>(chars), length); + } + template <typename CharT> JSAtom* lookup(const CharT* chars, size_t length) { switch (length) { |