Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: Source/wtf/Vector.h

Issue 332113002: VectorComparer should check null. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add tests Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/wtf/VectorTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | Source/wtf/VectorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698