equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved |
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved |
|
3 * Copyright (C) Research In Motion Limited 2009. All rights reserved. |
3 * |
4 * |
4 * This library is free software; you can redistribute it and/or |
5 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public |
6 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either |
7 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. |
8 * version 2 of the License, or (at your option) any later version. |
45 unsigned aLength = a->length(); |
46 unsigned aLength = a->length(); |
46 unsigned bLength = b->length(); |
47 unsigned bLength = b->length(); |
47 if (aLength != bLength) |
48 if (aLength != bLength) |
48 return false; |
49 return false; |
49 |
50 |
|
51 #if PLATFORM(ARM) || PLATFORM(SH4) |
|
52 const UChar* aChars = a->characters(); |
|
53 const UChar* bChars = b->characters(); |
|
54 for (unsigned i = 0; i != aLength; ++i) { |
|
55 if (*aChars++ != *bChars++) |
|
56 return false; |
|
57 } |
|
58 return true; |
|
59 #else |
|
60 /* Do it 4-bytes-at-a-time on architectures where it's safe */ |
50 const uint32_t* aChars = reinterpret_cast<const uint32_t*>(a->characters()); |
61 const uint32_t* aChars = reinterpret_cast<const uint32_t*>(a->characters()); |
51 const uint32_t* bChars = reinterpret_cast<const uint32_t*>(b->characters()); |
62 const uint32_t* bChars = reinterpret_cast<const uint32_t*>(b->characters()); |
52 |
63 |
53 unsigned halfLength = aLength >> 1; |
64 unsigned halfLength = aLength >> 1; |
54 for (unsigned i = 0; i != halfLength; ++i) |
65 for (unsigned i = 0; i != halfLength; ++i) |
57 |
68 |
58 if (aLength & 1 && *reinterpret_cast<const uint16_t*>(aChars) != *reinterpret_cast<const uint16_t*>(bChars)) |
69 if (aLength & 1 && *reinterpret_cast<const uint16_t*>(aChars) != *reinterpret_cast<const uint16_t*>(bChars)) |
59 return false; |
70 return false; |
60 |
71 |
61 return true; |
72 return true; |
|
73 #endif |
62 } |
74 } |
63 |
75 |
64 static unsigned hash(const RefPtr<StringImpl>& key) { return key->hash(); } |
76 static unsigned hash(const RefPtr<StringImpl>& key) { return key->hash(); } |
65 static bool equal(const RefPtr<StringImpl>& a, const RefPtr<StringImpl>& b) |
77 static bool equal(const RefPtr<StringImpl>& a, const RefPtr<StringImpl>& b) |
66 { |
78 { |