summaryrefslogtreecommitdiffstats
path: root/WebCore/platform
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2009-11-20 17:32:13 +0000
committerSteve Block <steveblock@google.com>2009-11-23 11:41:50 +0000
commit2a08945432ea7582d851faf9333b1649f340df56 (patch)
treebb830176641891ef2f87b8f1d41d740da4e45657 /WebCore/platform
parent6f781ac6264a1eb957adc5a410ae350ddeb2a6a2 (diff)
downloadexternal_webkit-2a08945432ea7582d851faf9333b1649f340df56.zip
external_webkit-2a08945432ea7582d851faf9333b1649f340df56.tar.gz
external_webkit-2a08945432ea7582d851faf9333b1649f340df56.tar.bz2
Update the Android-specific fix in StringHash::equal to match the fix recently made in webkit.org.
StringHash::equal includes an Android-specific fix for platforms which don't provide 4-byte alignment ... https://android-git.corp.google.com/w/?p=platform/external/webkit.git;a=commitdiff;h=05d23612a67d710479fb2359e98d7ac49a982025 This was recently fixed in webkit.org ... http://trac.webkit.org/changeset/51006 This patch updates Android to use the fix from webkit.org to avoid future merge conflicts. Background ... The fix in webkit.org uses a loop, whereas the Android fix uses memcmp. Tests by WebKit have apparently shown a loop to be faster than memcmp for small strings. This is consistent with an equivalent fix in AtomicString ... http://trac.webkit.org/changeset/19930 Change-Id: Ic9c0f729117e31bfdcb1bc1c28e85c048a464173
Diffstat (limited to 'WebCore/platform')
-rw-r--r--WebCore/platform/text/StringHash.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/WebCore/platform/text/StringHash.h b/WebCore/platform/text/StringHash.h
index 885dd8b..fc6cb3c 100644
--- a/WebCore/platform/text/StringHash.h
+++ b/WebCore/platform/text/StringHash.h
@@ -48,8 +48,15 @@ namespace WebCore {
return false;
#if PLATFORM(ARM) || PLATFORM(SH4)
- return memcmp(a->characters(), b->characters(), sizeof(UChar) * aLength) == 0;
+ 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());