]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - runtime/RegExpKey.h
JavaScriptCore-1218.tar.gz
[apple/javascriptcore.git] / runtime / RegExpKey.h
index b4847f97114d0039d50e2e25f529209e622edf26..58fa38725a182124616146ba73e4198181b5a20f 100644 (file)
@@ -28,8 +28,8 @@
 #ifndef RegExpKey_h
 #define RegExpKey_h
 
-#include "UString.h"
 #include <wtf/text/StringHash.h>
+#include <wtf/text/WTFString.h>
 
 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<typename T> struct DefaultHash;
-template<typename T> struct RegExpHash;
-
-template<> struct RegExpHash<JSC::RegExpKey> {
-    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<JSC::RegExpKey> {
-    typedef RegExpHash<JSC::RegExpKey> Hash;
+    typedef JSC::RegExpKey::Hash Hash;
 };
 
 template<> struct HashTraits<JSC::RegExpKey> : GenericHashTraits<JSC::RegExpKey> {
+    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; }
 };