OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 }; | 217 }; |
218 | 218 |
219 template<bool canCompareWithMemcmp, typename T> | 219 template<bool canCompareWithMemcmp, typename T> |
220 struct VectorComparer; | 220 struct VectorComparer; |
221 | 221 |
222 template<typename T> | 222 template<typename T> |
223 struct VectorComparer<false, T> | 223 struct VectorComparer<false, T> |
224 { | 224 { |
225 static bool compare(const T* a, const T* b, size_t size) | 225 static bool compare(const T* a, const T* b, size_t size) |
226 { | 226 { |
227 return std::equal(a, a + size, b); | 227 if (LIKELY(a && b)) |
| 228 return std::equal(a, a + size, b); |
| 229 return !a && !b; |
228 } | 230 } |
229 }; | 231 }; |
230 | 232 |
231 template<typename T> | 233 template<typename T> |
232 struct VectorComparer<true, T> | 234 struct VectorComparer<true, T> |
233 { | 235 { |
234 static bool compare(const T* a, const T* b, size_t size) | 236 static bool compare(const T* a, const T* b, size_t size) |
235 { | 237 { |
236 return memcmp(a, b, sizeof(T) * size) == 0; | 238 return memcmp(a, b, sizeof(T) * size) == 0; |
237 } | 239 } |
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 } | 1196 } |
1195 if (this->hasOutOfLineBuffer()) | 1197 if (this->hasOutOfLineBuffer()) |
1196 Allocator::markNoTracing(visitor, buffer()); | 1198 Allocator::markNoTracing(visitor, buffer()); |
1197 } | 1199 } |
1198 | 1200 |
1199 } // namespace WTF | 1201 } // namespace WTF |
1200 | 1202 |
1201 using WTF::Vector; | 1203 using WTF::Vector; |
1202 | 1204 |
1203 #endif // WTF_Vector_h | 1205 #endif // WTF_Vector_h |
OLD | NEW |