OLD | NEW |
---|---|
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_LIST_INL_H_ | 5 #ifndef V8_LIST_INL_H_ |
6 #define V8_LIST_INL_H_ | 6 #define V8_LIST_INL_H_ |
7 | 7 |
8 #include "src/list.h" | 8 #include "src/list.h" |
9 | 9 |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
(...skipping 15 matching lines...) Loading... | |
26 template<typename T, class P> | 26 template<typename T, class P> |
27 void List<T, P>::AddAll(const List<T, P>& other, P alloc) { | 27 void List<T, P>::AddAll(const List<T, P>& other, P alloc) { |
28 AddAll(other.ToVector(), alloc); | 28 AddAll(other.ToVector(), alloc); |
29 } | 29 } |
30 | 30 |
31 | 31 |
32 template<typename T, class P> | 32 template<typename T, class P> |
33 void List<T, P>::AddAll(const Vector<T>& other, P alloc) { | 33 void List<T, P>::AddAll(const Vector<T>& other, P alloc) { |
34 int result_length = length_ + other.length(); | 34 int result_length = length_ + other.length(); |
35 if (capacity_ < result_length) Resize(result_length, alloc); | 35 if (capacity_ < result_length) Resize(result_length, alloc); |
36 for (int i = 0; i < other.length(); i++) { | 36 if (std::is_fundamental<T>::value) { |
Sven Panne
2014/10/24 08:04:00
std:is_fundamental is a C++11 header feature, so w
| |
37 data_[length_ + i] = other.at(i); | 37 memcpy(data_ + length_, other.start(), sizeof(*data_) * other.length()); |
38 } else { | |
39 for (int i = 0; i < other.length(); i++) data_[length_ + i] = other.at(i); | |
38 } | 40 } |
39 length_ = result_length; | 41 length_ = result_length; |
40 } | 42 } |
41 | 43 |
42 | 44 |
43 // Use two layers of inlining so that the non-inlined function can | 45 // Use two layers of inlining so that the non-inlined function can |
44 // use the same implementation as the inlined version. | 46 // use the same implementation as the inlined version. |
45 template<typename T, class P> | 47 template<typename T, class P> |
46 void List<T, P>::ResizeAdd(const T& element, P alloc) { | 48 void List<T, P>::ResizeAdd(const T& element, P alloc) { |
47 ResizeAddInternal(element, alloc); | 49 ResizeAddInternal(element, alloc); |
(...skipping 204 matching lines...) Loading... | |
252 | 254 |
253 template <typename T> | 255 template <typename T> |
254 int SortedListBSearch(const List<T>& list, T elem) { | 256 int SortedListBSearch(const List<T>& list, T elem) { |
255 return SortedListBSearch<T, ElementCmp<T> > (list, ElementCmp<T>(elem)); | 257 return SortedListBSearch<T, ElementCmp<T> > (list, ElementCmp<T>(elem)); |
256 } | 258 } |
257 | 259 |
258 | 260 |
259 } } // namespace v8::internal | 261 } } // namespace v8::internal |
260 | 262 |
261 #endif // V8_LIST_INL_H_ | 263 #endif // V8_LIST_INL_H_ |
OLD | NEW |