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

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

Issue 2554693003: Migrate WTF::Vector::append() to ::push_back() [part 1 of N] (Closed)
Patch Set: rebase Created 4 years 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 | « third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp ('k') | no next file » | 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 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 if (size() * 2 < capacity()) 938 if (size() * 2 < capacity())
939 shrinkCapacity(size() + size() / 4 + 1); 939 shrinkCapacity(size() + size() / 4 + 1);
940 } 940 }
941 941
942 void clear() { shrinkCapacity(0); } 942 void clear() { shrinkCapacity(0); }
943 943
944 template <typename U> 944 template <typename U>
945 void append(const U*, size_t); 945 void append(const U*, size_t);
946 template <typename U> 946 template <typename U>
947 void append(U&&); 947 void append(U&&);
948 template <typename U>
949 void push_back(U&&);
948 template <typename... Args> 950 template <typename... Args>
949 T& emplace_back(Args&&...); 951 T& emplace_back(Args&&...);
950 template <typename U> 952 template <typename U>
951 void uncheckedAppend(U&& val); 953 void uncheckedAppend(U&& val);
952 template <typename U, size_t otherCapacity, typename V> 954 template <typename U, size_t otherCapacity, typename V>
953 void appendVector(const Vector<U, otherCapacity, V>&); 955 void appendVector(const Vector<U, otherCapacity, V>&);
954 956
955 template <typename U> 957 template <typename U>
956 void insert(size_t position, const U*, size_t); 958 void insert(size_t position, const U*, size_t);
957 template <typename U> 959 template <typename U>
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 RELEASE_ASSERT(newSize >= m_size); 1377 RELEASE_ASSERT(newSize >= m_size);
1376 T* dest = end(); 1378 T* dest = end();
1377 ANNOTATE_CHANGE_SIZE(begin(), capacity(), m_size, newSize); 1379 ANNOTATE_CHANGE_SIZE(begin(), capacity(), m_size, newSize);
1378 VectorCopier<VectorTraits<T>::canCopyWithMemcpy, T>::uninitializedCopy( 1380 VectorCopier<VectorTraits<T>::canCopyWithMemcpy, T>::uninitializedCopy(
1379 data, &data[dataSize], dest); 1381 data, &data[dataSize], dest);
1380 m_size = newSize; 1382 m_size = newSize;
1381 } 1383 }
1382 1384
1383 template <typename T, size_t inlineCapacity, typename Allocator> 1385 template <typename T, size_t inlineCapacity, typename Allocator>
1384 template <typename U> 1386 template <typename U>
1387 ALWAYS_INLINE void Vector<T, inlineCapacity, Allocator>::push_back(U&& val) {
1388 return append(std::forward<U>(val));
1389 }
1390
1391 template <typename T, size_t inlineCapacity, typename Allocator>
1392 template <typename U>
1385 ALWAYS_INLINE void Vector<T, inlineCapacity, Allocator>::append(U&& val) { 1393 ALWAYS_INLINE void Vector<T, inlineCapacity, Allocator>::append(U&& val) {
1386 ASSERT(Allocator::isAllocationAllowed()); 1394 ASSERT(Allocator::isAllocationAllowed());
1387 if (LIKELY(size() != capacity())) { 1395 if (LIKELY(size() != capacity())) {
1388 ANNOTATE_CHANGE_SIZE(begin(), capacity(), m_size, m_size + 1); 1396 ANNOTATE_CHANGE_SIZE(begin(), capacity(), m_size, m_size + 1);
1389 new (NotNull, end()) T(std::forward<U>(val)); 1397 new (NotNull, end()) T(std::forward<U>(val));
1390 ++m_size; 1398 ++m_size;
1391 return; 1399 return;
1392 } 1400 }
1393 1401
1394 appendSlowCase(std::forward<U>(val)); 1402 appendSlowCase(std::forward<U>(val));
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1605 visitor, *const_cast<T*>(bufferEntry)); 1613 visitor, *const_cast<T*>(bufferEntry));
1606 checkUnusedSlots(buffer() + size(), buffer() + capacity()); 1614 checkUnusedSlots(buffer() + size(), buffer() + capacity());
1607 } 1615 }
1608 } 1616 }
1609 1617
1610 } // namespace WTF 1618 } // namespace WTF
1611 1619
1612 using WTF::Vector; 1620 using WTF::Vector;
1613 1621
1614 #endif // WTF_Vector_h 1622 #endif // WTF_Vector_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698