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

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

Issue 1370933002: Return early for vec.remove(position, 0). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add unit test Created 5 years, 2 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 | third_party/WebKit/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 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 TypeOperations::moveOverlapping(spot + 1, end(), spot); 1257 TypeOperations::moveOverlapping(spot + 1, end(), spot);
1258 clearUnusedSlots(end() - 1, end()); 1258 clearUnusedSlots(end() - 1, end());
1259 ANNOTATE_CHANGE_SIZE(begin(), capacity(), m_size, m_size - 1); 1259 ANNOTATE_CHANGE_SIZE(begin(), capacity(), m_size, m_size - 1);
1260 --m_size; 1260 --m_size;
1261 } 1261 }
1262 1262
1263 template<typename T, size_t inlineCapacity, typename Allocator> 1263 template<typename T, size_t inlineCapacity, typename Allocator>
1264 inline void Vector<T, inlineCapacity, Allocator>::remove(size_t position, si ze_t length) 1264 inline void Vector<T, inlineCapacity, Allocator>::remove(size_t position, si ze_t length)
1265 { 1265 {
1266 ASSERT_WITH_SECURITY_IMPLICATION(position <= size()); 1266 ASSERT_WITH_SECURITY_IMPLICATION(position <= size());
1267 if (!length)
1268 return;
1267 RELEASE_ASSERT(position + length <= size()); 1269 RELEASE_ASSERT(position + length <= size());
1268 T* beginSpot = begin() + position; 1270 T* beginSpot = begin() + position;
1269 T* endSpot = beginSpot + length; 1271 T* endSpot = beginSpot + length;
1270 TypeOperations::destruct(beginSpot, endSpot); 1272 TypeOperations::destruct(beginSpot, endSpot);
1271 TypeOperations::moveOverlapping(endSpot, end(), beginSpot); 1273 TypeOperations::moveOverlapping(endSpot, end(), beginSpot);
1272 clearUnusedSlots(end() - length, end()); 1274 clearUnusedSlots(end() - length, end());
1273 ANNOTATE_CHANGE_SIZE(begin(), capacity(), m_size, m_size - length); 1275 ANNOTATE_CHANGE_SIZE(begin(), capacity(), m_size, m_size - length);
1274 m_size -= length; 1276 m_size -= length;
1275 } 1277 }
1276 1278
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 struct NeedsTracing<Vector<T, N>> { 1338 struct NeedsTracing<Vector<T, N>> {
1337 static const bool value = false; 1339 static const bool value = false;
1338 }; 1340 };
1339 #endif 1341 #endif
1340 1342
1341 } // namespace WTF 1343 } // namespace WTF
1342 1344
1343 using WTF::Vector; 1345 using WTF::Vector;
1344 1346
1345 #endif // WTF_Vector_h 1347 #endif // WTF_Vector_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/VectorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698