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

Unified Diff: runtime/vm/growable_array.h

Issue 324203003: Add SetLength to GrowableArray and use it in code coverage. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/coverage.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/growable_array.h
===================================================================
--- runtime/vm/growable_array.h (revision 37203)
+++ runtime/vm/growable_array.h (working copy)
@@ -83,6 +83,9 @@
data_[idx] = value;
}
+ // The content is uninitialized after calling it.
+ void SetLength(intptr_t new_length);
+
// Sort the array in place.
inline void Sort(int compare(const T*, const T*));
@@ -92,6 +95,7 @@
T* data_;
Zone* zone_; // Zone in which we are allocating the array.
+ // Used for growing the array.
void Resize(intptr_t new_length);
DISALLOW_COPY_AND_ASSIGN(BaseGrowableArray);
@@ -119,6 +123,18 @@
}
+template<typename T, typename B>
+void BaseGrowableArray<T, B>::SetLength(intptr_t new_length) {
+ if (new_length > capacity_) {
+ T* new_data = zone_->Alloc<T>(new_length);
+ ASSERT(new_data != NULL);
+ data_ = new_data;
+ capacity_ = new_length;
+ }
+ length_ = new_length;
+}
+
+
template<typename T>
class GrowableArray : public BaseGrowableArray<T, ValueObject> {
public:
« no previous file with comments | « runtime/vm/coverage.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698