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

Side by Side Diff: runtime/vm/growable_array.h

Issue 2641243002: Removed usage of std::map and std::vector from kernel code. Issue #28064. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | runtime/vm/kernel_binary.cc » ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // Defines growable array classes, that differ where they are allocated: 4 // Defines growable array classes, that differ where they are allocated:
5 // - GrowableArray: allocated on stack. 5 // - GrowableArray: allocated on stack.
6 // - ZoneGrowableArray: allocated in the zone. 6 // - ZoneGrowableArray: allocated in the zone.
7 // - MallocGrowableArray: allocates using malloc/realloc; free is only called 7 // - MallocGrowableArray: allocates using malloc/realloc; free is only called
8 // at destruction. 8 // at destruction.
9 9
10 #ifndef RUNTIME_VM_GROWABLE_ARRAY_H_ 10 #ifndef RUNTIME_VM_GROWABLE_ARRAY_H_
(...skipping 20 matching lines...) Expand all
31 } 31 }
32 } 32 }
33 33
34 ~BaseGrowableArray() { allocator_->template Free<T>(data_, capacity_); } 34 ~BaseGrowableArray() { allocator_->template Free<T>(data_, capacity_); }
35 35
36 intptr_t length() const { return length_; } 36 intptr_t length() const { return length_; }
37 T* data() const { return data_; } 37 T* data() const { return data_; }
38 bool is_empty() const { return length_ == 0; } 38 bool is_empty() const { return length_ == 0; }
39 39
40 void TruncateTo(intptr_t length) { 40 void TruncateTo(intptr_t length) {
41 ASSERT(length_ >= length); 41 ASSERT(length >= 0);
42 ASSERT(static_cast<uintptr_t>(length_) >= static_cast<uintptr_t>(length));
bkonyi 2017/01/19 20:48:46 The compiler was complaining that doing length_ >=
zra 2017/01/19 21:06:25 I think it's not worried about overflow here, but
bkonyi 2017/01/20 23:56:28 See comment in new patch in kernel_binary.
42 length_ = length; 43 length_ = length;
43 } 44 }
44 45
45 void Add(const T& value) { 46 void Add(const T& value) {
46 Resize(length() + 1); 47 Resize(length() + 1);
47 Last() = value; 48 Last() = value;
48 } 49 }
49 50
50 T& RemoveLast() { 51 T& RemoveLast() {
51 ASSERT(length_ > 0); 52 ASSERT(length_ > 0);
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 class MallocGrowableArray : public BaseGrowableArray<T, EmptyBase, Malloc> { 275 class MallocGrowableArray : public BaseGrowableArray<T, EmptyBase, Malloc> {
275 public: 276 public:
276 explicit MallocGrowableArray(intptr_t initial_capacity) 277 explicit MallocGrowableArray(intptr_t initial_capacity)
277 : BaseGrowableArray<T, EmptyBase, Malloc>(initial_capacity, NULL) {} 278 : BaseGrowableArray<T, EmptyBase, Malloc>(initial_capacity, NULL) {}
278 MallocGrowableArray() : BaseGrowableArray<T, EmptyBase, Malloc>(NULL) {} 279 MallocGrowableArray() : BaseGrowableArray<T, EmptyBase, Malloc>(NULL) {}
279 }; 280 };
280 281
281 } // namespace dart 282 } // namespace dart
282 283
283 #endif // RUNTIME_VM_GROWABLE_ARRAY_H_ 284 #endif // RUNTIME_VM_GROWABLE_ARRAY_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/kernel_binary.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698