X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/14957cd040308e3eeec43d26bae5d76da13fcd85..refs/heads/master:/runtime/RegExpKey.h diff --git a/runtime/RegExpKey.h b/runtime/RegExpKey.h index b4847f9..58fa387 100644 --- a/runtime/RegExpKey.h +++ b/runtime/RegExpKey.h @@ -28,8 +28,8 @@ #ifndef RegExpKey_h #define RegExpKey_h -#include "UString.h" #include +#include namespace JSC { @@ -56,7 +56,7 @@ struct RegExpKey { { } - RegExpKey(RegExpFlags flags, const UString& pattern) + RegExpKey(RegExpFlags flags, const String& pattern) : flagsValue(flags) , pattern(pattern.impl()) { @@ -73,9 +73,17 @@ struct RegExpKey { , pattern(pattern) { } + + friend inline bool operator==(const RegExpKey& a, const RegExpKey& b); + + struct Hash { + static unsigned hash(const RegExpKey& key) { return key.pattern->hash(); } + static bool equal(const RegExpKey& a, const RegExpKey& b) { return a == b; } + static const bool safeToCompareToEmptyOrDeleted = false; + }; }; -inline bool operator==(const RegExpKey& a, const RegExpKey& b) +inline bool operator==(const RegExpKey& a, const RegExpKey& b) { if (a.flagsValue != b.flagsValue) return false; @@ -90,19 +98,13 @@ inline bool operator==(const RegExpKey& a, const RegExpKey& b) namespace WTF { template struct DefaultHash; -template struct RegExpHash; - -template<> struct RegExpHash { - static unsigned hash(const JSC::RegExpKey& key) { return key.pattern->hash(); } - static bool equal(const JSC::RegExpKey& a, const JSC::RegExpKey& b) { return a == b; } - static const bool safeToCompareToEmptyOrDeleted = false; -}; template<> struct DefaultHash { - typedef RegExpHash Hash; + typedef JSC::RegExpKey::Hash Hash; }; template<> struct HashTraits : GenericHashTraits { + static const bool emptyValueIsZero = true; static void constructDeletedValue(JSC::RegExpKey& slot) { slot.flagsValue = JSC::DeletedValueFlags; } static bool isDeletedValue(const JSC::RegExpKey& value) { return value.flagsValue == JSC::DeletedValueFlags; } };