Title: [152438] trunk/Source/WTF
Revision
152438
Author
[email protected]
Date
2013-07-06 23:46:39 -0700 (Sat, 06 Jul 2013)

Log Message

Fix the performance regressions introduced by r152418
https://bugs.webkit.org/show_bug.cgi?id=118438

Reviewed by Sam Weinig.

* wtf/text/StringImpl.h:
(WTF::equal):
Looping between two arbitrary pointers prevents important loop
optimizations.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (152437 => 152438)


--- trunk/Source/WTF/ChangeLog	2013-07-06 20:08:48 UTC (rev 152437)
+++ trunk/Source/WTF/ChangeLog	2013-07-07 06:46:39 UTC (rev 152438)
@@ -1,3 +1,15 @@
+2013-07-06  Benjamin Poulain  <[email protected]>
+
+        Fix the performance regressions introduced by r152418
+        https://bugs.webkit.org/show_bug.cgi?id=118438
+
+        Reviewed by Sam Weinig.
+
+        * wtf/text/StringImpl.h:
+        (WTF::equal):
+        Looping between two arbitrary pointers prevents important loop
+        optimizations.
+
 2013-07-05  Brent Fulgham  <[email protected]>
 
         [Windows] Unreviewed build correction.

Modified: trunk/Source/WTF/wtf/text/StringImpl.h (152437 => 152438)


--- trunk/Source/WTF/wtf/text/StringImpl.h	2013-07-06 20:08:48 UTC (rev 152437)
+++ trunk/Source/WTF/wtf/text/StringImpl.h	2013-07-07 06:46:39 UTC (rev 152438)
@@ -1077,12 +1077,21 @@
     return isEqual;
 }
 #else
-ALWAYS_INLINE bool equal(const LChar* a, const LChar* b, unsigned length) { return std::equal(a, a + length, b); }
-ALWAYS_INLINE bool equal(const UChar* a, const UChar* b, unsigned length) { return std::equal(a, a + length, b); }
+ALWAYS_INLINE bool equal(const LChar* a, const LChar* b, unsigned length) { return !memcmp(a, b, length); }
+ALWAYS_INLINE bool equal(const UChar* a, const UChar* b, unsigned length) { return !memcmp(a, b, length * sizeof(UChar)); }
 #endif
 
-ALWAYS_INLINE bool equal(const LChar* a, const UChar* b, unsigned length) { return std::equal(a, a + length, b); }
-ALWAYS_INLINE bool equal(const UChar* a, const LChar* b, unsigned length) { return std::equal(a, a + length, b); }
+ALWAYS_INLINE bool equal(const LChar* a, const UChar* b, unsigned length)
+{
+    for (unsigned i = 0; i < length; ++i) {
+        if (a[i] != b[i])
+            return false;
+    }
+    return true;
+}
+
+ALWAYS_INLINE bool equal(const UChar* a, const LChar* b, unsigned length) { return equal(b, a, length); }
+
 WTF_EXPORT_STRING_API bool equalIgnoringCase(const StringImpl*, const StringImpl*);
 WTF_EXPORT_STRING_API bool equalIgnoringCase(const StringImpl*, const LChar*);
 inline bool equalIgnoringCase(const LChar* a, const StringImpl* b) { return equalIgnoringCase(b, a); }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to