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

Unified Diff: mojo/public/cpp/bindings/array.h

Issue 2380643003: Mojo C++ bindings: Add mojo::Array<T>::reserve() (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/array.h
diff --git a/mojo/public/cpp/bindings/array.h b/mojo/public/cpp/bindings/array.h
index a253da1f3954eed84541177cfee46df4c17a7dfa..973aa08ab4ff7a4c137ac03d884cc6edb68da831 100644
--- a/mojo/public/cpp/bindings/array.h
+++ b/mojo/public/cpp/bindings/array.h
@@ -133,6 +133,11 @@ class Array {
// Sets the array to empty (even if previously it was null.)
void SetToEmpty() { resize(0); }
+ // Ensures the underlying storage can store up to |size| elements without
+ // performing reallocations. This works like the reserve method of
+ // |std::vector|.
+ void reserve(size_t size) { vec_.reserve(size); }
+
// Returns a const reference to the |std::vector| managed by this class. If
// the array is null, this will be an empty vector.
const std::vector<T>& storage() const { return vec_; }
« 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