Changeset 19631 in webkit
- Timestamp:
- Feb 14, 2007, 3:42:44 PM (18 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r19613 r19631 1 2007-02-14 Anders Carlsson <acarlsson@apple.com> 2 3 Reviewed by Darin. 4 5 Add new canCompareWithMemcmp vector trait and use it to determine whether 6 operator== can use memcmp. 7 8 * wtf/Vector.h: 9 (WTF::): 10 (WTF::VectorTypeOperations::compare): 11 (WTF::operator==): 12 * wtf/VectorTraits.h: 13 (WTF::): 14 1 15 2007-02-13 Brady Eidson <beidson@apple.com> 2 16 -
trunk/JavaScriptCore/wtf/Vector.h
r19613 r19631 177 177 }; 178 178 179 template<bool canCompareWithMemcmp, typename T> 180 class VectorComparer; 181 182 template<typename T> 183 struct VectorComparer<false, T> 184 { 185 static bool compare(const T* a, const T* b, size_t size) 186 { 187 for (size_t i = 0; i < size; ++i) 188 if (a[i] != b[i]) 189 return false; 190 return false; 191 } 192 }; 193 194 template<typename T> 195 struct VectorComparer<true, T> 196 { 197 static bool compare(const T* a, const T* b, size_t size) 198 { 199 return memcmp(a, b, sizeof(T) * size) == 0; 200 } 201 }; 202 179 203 template<typename T> 180 204 struct VectorTypeOperations … … 208 232 { 209 233 VectorFiller<VectorTraits<T>::canFillWithMemset, T>::uninitializedFill(dst, dstEnd, val); 234 } 235 236 static bool compare(const T* a, const T* b, size_t size) 237 { 238 return VectorComparer<VectorTraits<T>::canCompareWithMemcmp, T>::compare(a, b, size); 210 239 } 211 240 }; … … 669 698 return false; 670 699 671 for (size_t i = 0; i < a.size(); ++i) 672 if (a.at(i) != b.at(i)) 673 return false; 674 675 return true; 700 return VectorTypeOperations<T>::compare(a.data(), b.data(), a.size()); 676 701 } 677 702 -
trunk/JavaScriptCore/wtf/VectorTraits.h
r17127 r19631 61 61 static const bool canCopyWithMemcpy = false; 62 62 static const bool canFillWithMemset = false; 63 static const bool canCompareWithMemcmp = false; 63 64 }; 64 65 … … 72 73 static const bool canCopyWithMemcpy = true; 73 74 static const bool canFillWithMemset = sizeof(T) == sizeof(char); 75 static const bool canCompareWithMemcmp = true; 74 76 }; 75 77 … … 85 87 static const bool canCopyWithMemcpy = false; 86 88 static const bool canFillWithMemset = false; 89 static const bool canCompareWithMemcmp = true; 87 90 }; 88 91 … … 104 107 static const bool canCopyWithMemcpy = FirstTraits::canCopyWithMemcpy && SecondTraits::canCopyWithMemcpy; 105 108 static const bool canFillWithMemset = false; 109 static const bool canCompareWithMemcmp = FirstTraits::canCompareWithMemcmp && SecondTraits::canCompareWithMemcmp; 106 110 }; 107 111
Note:
See TracChangeset
for help on using the changeset viewer.