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

Side by Side Diff: src/list-inl.h

Issue 430503007: Rename ASSERT* to DCHECK*. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE and fixes Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/list.h ('k') | src/lithium.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // Use two layers of inlining so that the non-inlined function can 43 // Use two layers of inlining so that the non-inlined function can
44 // use the same implementation as the inlined version. 44 // use the same implementation as the inlined version.
45 template<typename T, class P> 45 template<typename T, class P>
46 void List<T, P>::ResizeAdd(const T& element, P alloc) { 46 void List<T, P>::ResizeAdd(const T& element, P alloc) {
47 ResizeAddInternal(element, alloc); 47 ResizeAddInternal(element, alloc);
48 } 48 }
49 49
50 50
51 template<typename T, class P> 51 template<typename T, class P>
52 void List<T, P>::ResizeAddInternal(const T& element, P alloc) { 52 void List<T, P>::ResizeAddInternal(const T& element, P alloc) {
53 ASSERT(length_ >= capacity_); 53 DCHECK(length_ >= capacity_);
54 // Grow the list capacity by 100%, but make sure to let it grow 54 // Grow the list capacity by 100%, but make sure to let it grow
55 // even when the capacity is zero (possible initial case). 55 // even when the capacity is zero (possible initial case).
56 int new_capacity = 1 + 2 * capacity_; 56 int new_capacity = 1 + 2 * capacity_;
57 // Since the element reference could be an element of the list, copy 57 // Since the element reference could be an element of the list, copy
58 // it out of the old backing storage before resizing. 58 // it out of the old backing storage before resizing.
59 T temp = element; 59 T temp = element;
60 Resize(new_capacity, alloc); 60 Resize(new_capacity, alloc);
61 data_[length_++] = temp; 61 data_[length_++] = temp;
62 } 62 }
63 63
64 64
65 template<typename T, class P> 65 template<typename T, class P>
66 void List<T, P>::Resize(int new_capacity, P alloc) { 66 void List<T, P>::Resize(int new_capacity, P alloc) {
67 ASSERT_LE(length_, new_capacity); 67 DCHECK_LE(length_, new_capacity);
68 T* new_data = NewData(new_capacity, alloc); 68 T* new_data = NewData(new_capacity, alloc);
69 MemCopy(new_data, data_, length_ * sizeof(T)); 69 MemCopy(new_data, data_, length_ * sizeof(T));
70 List<T, P>::DeleteData(data_); 70 List<T, P>::DeleteData(data_);
71 data_ = new_data; 71 data_ = new_data;
72 capacity_ = new_capacity; 72 capacity_ = new_capacity;
73 } 73 }
74 74
75 75
76 template<typename T, class P> 76 template<typename T, class P>
77 Vector<T> List<T, P>::AddBlock(T value, int count, P alloc) { 77 Vector<T> List<T, P>::AddBlock(T value, int count, P alloc) {
78 int start = length_; 78 int start = length_;
79 for (int i = 0; i < count; i++) Add(value, alloc); 79 for (int i = 0; i < count; i++) Add(value, alloc);
80 return Vector<T>(&data_[start], count); 80 return Vector<T>(&data_[start], count);
81 } 81 }
82 82
83 83
84 template<typename T, class P> 84 template<typename T, class P>
85 void List<T, P>::Set(int index, const T& elm) { 85 void List<T, P>::Set(int index, const T& elm) {
86 ASSERT(index >= 0 && index <= length_); 86 DCHECK(index >= 0 && index <= length_);
87 data_[index] = elm; 87 data_[index] = elm;
88 } 88 }
89 89
90 90
91 template<typename T, class P> 91 template<typename T, class P>
92 void List<T, P>::InsertAt(int index, const T& elm, P alloc) { 92 void List<T, P>::InsertAt(int index, const T& elm, P alloc) {
93 ASSERT(index >= 0 && index <= length_); 93 DCHECK(index >= 0 && index <= length_);
94 Add(elm, alloc); 94 Add(elm, alloc);
95 for (int i = length_ - 1; i > index; --i) { 95 for (int i = length_ - 1; i > index; --i) {
96 data_[i] = data_[i - 1]; 96 data_[i] = data_[i - 1];
97 } 97 }
98 data_[index] = elm; 98 data_[index] = elm;
99 } 99 }
100 100
101 101
102 template<typename T, class P> 102 template<typename T, class P>
103 T List<T, P>::Remove(int i) { 103 T List<T, P>::Remove(int i) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // We don't call Initialize(0) since that requires passing a Zone, 137 // We don't call Initialize(0) since that requires passing a Zone,
138 // which we don't really need. 138 // which we don't really need.
139 data_ = NULL; 139 data_ = NULL;
140 capacity_ = 0; 140 capacity_ = 0;
141 length_ = 0; 141 length_ = 0;
142 } 142 }
143 143
144 144
145 template<typename T, class P> 145 template<typename T, class P>
146 void List<T, P>::Rewind(int pos) { 146 void List<T, P>::Rewind(int pos) {
147 ASSERT(0 <= pos && pos <= length_); 147 DCHECK(0 <= pos && pos <= length_);
148 length_ = pos; 148 length_ = pos;
149 } 149 }
150 150
151 151
152 template<typename T, class P> 152 template<typename T, class P>
153 void List<T, P>::Trim(P alloc) { 153 void List<T, P>::Trim(P alloc) {
154 if (length_ < capacity_ / 4) { 154 if (length_ < capacity_ / 4) {
155 Resize(capacity_ / 2, alloc); 155 Resize(capacity_ / 2, alloc);
156 } 156 }
157 } 157 }
(...skipping 30 matching lines...) Expand all
188 } 188 }
189 return result; 189 return result;
190 } 190 }
191 191
192 192
193 template<typename T, class P> 193 template<typename T, class P>
194 void List<T, P>::Sort(int (*cmp)(const T* x, const T* y)) { 194 void List<T, P>::Sort(int (*cmp)(const T* x, const T* y)) {
195 ToVector().Sort(cmp); 195 ToVector().Sort(cmp);
196 #ifdef DEBUG 196 #ifdef DEBUG
197 for (int i = 1; i < length_; i++) 197 for (int i = 1; i < length_; i++)
198 ASSERT(cmp(&data_[i - 1], &data_[i]) <= 0); 198 DCHECK(cmp(&data_[i - 1], &data_[i]) <= 0);
199 #endif 199 #endif
200 } 200 }
201 201
202 202
203 template<typename T, class P> 203 template<typename T, class P>
204 void List<T, P>::Sort() { 204 void List<T, P>::Sort() {
205 ToVector().Sort(); 205 ToVector().Sort();
206 } 206 }
207 207
208 208
209 template<typename T, class P> 209 template<typename T, class P>
210 void List<T, P>::Initialize(int capacity, P allocator) { 210 void List<T, P>::Initialize(int capacity, P allocator) {
211 ASSERT(capacity >= 0); 211 DCHECK(capacity >= 0);
212 data_ = (capacity > 0) ? NewData(capacity, allocator) : NULL; 212 data_ = (capacity > 0) ? NewData(capacity, allocator) : NULL;
213 capacity_ = capacity; 213 capacity_ = capacity;
214 length_ = 0; 214 length_ = 0;
215 } 215 }
216 216
217 217
218 template <typename T, typename P> 218 template <typename T, typename P>
219 int SortedListBSearch(const List<T>& list, P cmp) { 219 int SortedListBSearch(const List<T>& list, P cmp) {
220 int low = 0; 220 int low = 0;
221 int high = list.length() - 1; 221 int high = list.length() - 1;
(...skipping 30 matching lines...) Expand all
252 252
253 template <typename T> 253 template <typename T>
254 int SortedListBSearch(const List<T>& list, T elem) { 254 int SortedListBSearch(const List<T>& list, T elem) {
255 return SortedListBSearch<T, ElementCmp<T> > (list, ElementCmp<T>(elem)); 255 return SortedListBSearch<T, ElementCmp<T> > (list, ElementCmp<T>(elem));
256 } 256 }
257 257
258 258
259 } } // namespace v8::internal 259 } } // namespace v8::internal
260 260
261 #endif // V8_LIST_INL_H_ 261 #endif // V8_LIST_INL_H_
OLDNEW
« no previous file with comments | « src/list.h ('k') | src/lithium.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698