| 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 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_LIST_INL_H_ | 28 #ifndef V8_LIST_INL_H_ |
| 29 #define V8_LIST_INL_H_ | 29 #define V8_LIST_INL_H_ |
| 30 | 30 |
| 31 #include "list.h" | 31 #include "list.h" |
| 32 #include "platform.h" |
| 32 | 33 |
| 33 namespace v8 { | 34 namespace v8 { |
| 34 namespace internal { | 35 namespace internal { |
| 35 | 36 |
| 36 | 37 |
| 37 template<typename T, class P> | 38 template<typename T, class P> |
| 38 void List<T, P>::Add(const T& element, P alloc) { | 39 void List<T, P>::Add(const T& element, P alloc) { |
| 39 if (length_ < capacity_) { | 40 if (length_ < capacity_) { |
| 40 data_[length_++] = element; | 41 data_[length_++] = element; |
| 41 } else { | 42 } else { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 T temp = element; | 81 T temp = element; |
| 81 Resize(new_capacity, alloc); | 82 Resize(new_capacity, alloc); |
| 82 data_[length_++] = temp; | 83 data_[length_++] = temp; |
| 83 } | 84 } |
| 84 | 85 |
| 85 | 86 |
| 86 template<typename T, class P> | 87 template<typename T, class P> |
| 87 void List<T, P>::Resize(int new_capacity, P alloc) { | 88 void List<T, P>::Resize(int new_capacity, P alloc) { |
| 88 ASSERT_LE(length_, new_capacity); | 89 ASSERT_LE(length_, new_capacity); |
| 89 T* new_data = NewData(new_capacity, alloc); | 90 T* new_data = NewData(new_capacity, alloc); |
| 90 memcpy(new_data, data_, length_ * sizeof(T)); | 91 OS::MemCopy(new_data, data_, length_ * sizeof(T)); |
| 91 List<T, P>::DeleteData(data_); | 92 List<T, P>::DeleteData(data_); |
| 92 data_ = new_data; | 93 data_ = new_data; |
| 93 capacity_ = new_capacity; | 94 capacity_ = new_capacity; |
| 94 } | 95 } |
| 95 | 96 |
| 96 | 97 |
| 97 template<typename T, class P> | 98 template<typename T, class P> |
| 98 Vector<T> List<T, P>::AddBlock(T value, int count, P alloc) { | 99 Vector<T> List<T, P>::AddBlock(T value, int count, P alloc) { |
| 99 int start = length_; | 100 int start = length_; |
| 100 for (int i = 0; i < count; i++) Add(value, alloc); | 101 for (int i = 0; i < count; i++) Add(value, alloc); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 | 266 |
| 266 template <typename T> | 267 template <typename T> |
| 267 int SortedListBSearch(const List<T>& list, T elem) { | 268 int SortedListBSearch(const List<T>& list, T elem) { |
| 268 return SortedListBSearch<T, ElementCmp<T> > (list, ElementCmp<T>(elem)); | 269 return SortedListBSearch<T, ElementCmp<T> > (list, ElementCmp<T>(elem)); |
| 269 } | 270 } |
| 270 | 271 |
| 271 | 272 |
| 272 } } // namespace v8::internal | 273 } } // namespace v8::internal |
| 273 | 274 |
| 274 #endif // V8_LIST_INL_H_ | 275 #endif // V8_LIST_INL_H_ |
| OLD | NEW |