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

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

Issue 422853005: Revert "Fix a potential overflow in SortedListBSearch". (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 | « no previous file | 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 // 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
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;
222 while (low <= high) { 222 while (low <= high) {
223 int mid = low + (high - low) / 2; 223 int mid = (low + high) / 2;
224 T mid_elem = list[mid]; 224 T mid_elem = list[mid];
225 225
226 if (cmp(&mid_elem) > 0) { 226 if (cmp(&mid_elem) > 0) {
227 high = mid - 1; 227 high = mid - 1;
228 continue; 228 continue;
229 } 229 }
230 if (cmp(&mid_elem) < 0) { 230 if (cmp(&mid_elem) < 0) {
231 low = mid + 1; 231 low = mid + 1;
232 continue; 232 continue;
233 } 233 }
(...skipping 18 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 | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698