[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

barraclough at apple.com barraclough at apple.com
Wed Dec 22 12:12:05 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 2b3f9c54007a531e53f67890a1ae345e1edce314
Author: barraclough at apple.com <barraclough at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Aug 17 02:21:26 2010 +0000

    Add VectorTraits to String & DefaultHash traits to UString to unify behaviour.
    
    Rubber stamped by Sam Weinig
    
    * runtime/UString.h:
    (JSC::UStringHash::hash):
    (JSC::UStringHash::equal):
    (WTF::):
    * wtf/text/WTFString.h:
    (WTF::):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65479 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 7b581a9..2e11c2c 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -2,6 +2,19 @@
 
         Rubber stamped by Sam Weinig
 
+        Add VectorTraits to String & DefaultHash traits to UString to unify behaviour.
+
+        * runtime/UString.h:
+        (JSC::UStringHash::hash):
+        (JSC::UStringHash::equal):
+        (WTF::):
+        * wtf/text/WTFString.h:
+        (WTF::):
+
+2010-08-16  Gavin Barraclough  <barraclough at apple.com>
+
+        Rubber stamped by Sam Weinig
+
         Remove unnecessary includes from UString.h, add new includes as necessary.
 
         * profiler/CallIdentifier.h:
diff --git a/JavaScriptCore/runtime/UString.h b/JavaScriptCore/runtime/UString.h
index add8ebe..6567299 100644
--- a/JavaScriptCore/runtime/UString.h
+++ b/JavaScriptCore/runtime/UString.h
@@ -194,10 +194,72 @@ inline int codePointCompare(const UString& s1, const UString& s2)
     return codePointCompare(s1.impl(), s2.impl());
 }
 
+struct UStringHash {
+    static unsigned hash(StringImpl* key) { return key->hash(); }
+    static bool equal(const StringImpl* a, const StringImpl* b)
+    {
+        if (a == b)
+            return true;
+        if (!a || !b)
+            return false;
+
+        unsigned aLength = a->length();
+        unsigned bLength = b->length();
+        if (aLength != bLength)
+            return false;
+
+        // FIXME: perhaps we should have a more abstract macro that indicates when
+        // going 4 bytes at a time is unsafe
+#if CPU(ARM) || CPU(SH4)
+        const UChar* aChars = a->characters();
+        const UChar* bChars = b->characters();
+        for (unsigned i = 0; i != aLength; ++i) {
+            if (*aChars++ != *bChars++)
+                return false;
+        }
+        return true;
+#else
+        /* Do it 4-bytes-at-a-time on architectures where it's safe */
+        const uint32_t* aChars = reinterpret_cast<const uint32_t*>(a->characters());
+        const uint32_t* bChars = reinterpret_cast<const uint32_t*>(b->characters());
+
+        unsigned halfLength = aLength >> 1;
+        for (unsigned i = 0; i != halfLength; ++i)
+            if (*aChars++ != *bChars++)
+                return false;
+
+        if (aLength & 1 && *reinterpret_cast<const uint16_t*>(aChars) != *reinterpret_cast<const uint16_t*>(bChars))
+            return false;
+
+        return true;
+#endif
+    }
+
+    static unsigned hash(const RefPtr<StringImpl>& key) { return key->hash(); }
+    static bool equal(const RefPtr<StringImpl>& a, const RefPtr<StringImpl>& b)
+    {
+        return equal(a.get(), b.get());
+    }
+
+    static unsigned hash(const UString& key) { return key.impl()->hash(); }
+    static bool equal(const UString& a, const UString& b)
+    {
+        return equal(a.impl(), b.impl());
+    }
+
+    static const bool safeToCompareToEmptyOrDeleted = false;
+};
+
 } // namespace JSC
 
 namespace WTF {
 
+// UStringHash is the default hash for UString
+template<typename T> struct DefaultHash;
+template<> struct DefaultHash<JSC::UString> {
+    typedef JSC::UStringHash Hash;
+};
+
 template <> struct VectorTraits<JSC::UString> : SimpleClassVectorTraits
 {
     static const bool canInitializeWithMemset = true;
diff --git a/JavaScriptCore/wtf/text/WTFString.h b/JavaScriptCore/wtf/text/WTFString.h
index 5627307..6344ca1 100644
--- a/JavaScriptCore/wtf/text/WTFString.h
+++ b/JavaScriptCore/wtf/text/WTFString.h
@@ -430,6 +430,11 @@ template<> struct DefaultHash<String> {
     typedef StringHash Hash;
 };
 
+template <> struct VectorTraits<String> : SimpleClassVectorTraits
+{
+    static const bool canInitializeWithMemset = true;
+};
+
 }
 
 using WTF::CString;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list