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

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

Issue 1397133002: Remove callers of mojo::Array<size_t> constructor in favor of ::New (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 2 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 | « mojo/dart/embedder/test/dart_to_cpp_tests.cc ('k') | mojo/public/cpp/bindings/lib/array_serialization.h » ('j') | 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 e765bb1a43eed4fb26ff53fcc346a7d5489dd840..b6b3f47712f33d1f9aa5e6627bfa9a5e740e4d65 100644
--- a/mojo/public/cpp/bindings/array.h
+++ b/mojo/public/cpp/bindings/array.h
@@ -56,7 +56,11 @@ class Array {
// Creates a non-null array of the specified size. The elements will be
// value-initialized (meaning that they will be initialized by their default
// constructor, if any, or else zero-initialized).
- static Array New(size_t size) { return Array(size).Pass(); }
+ static Array New(size_t size) {
+ Array ret;
+ ret.resize(size);
+ return ret;
+ }
// Creates a new array with a copy of the contents of |other|.
template <typename U>
@@ -256,7 +260,7 @@ class Array {
template <typename T, typename E>
struct TypeConverter<Array<T>, std::vector<E>> {
static Array<T> Convert(const std::vector<E>& input) {
- Array<T> result(input.size());
+ auto result = Array<T>::New(input.size());
for (size_t i = 0; i < input.size(); ++i)
result[i] = TypeConverter<T, E>::Convert(input[i]);
return result.Pass();
@@ -285,7 +289,7 @@ struct TypeConverter<std::vector<E>, Array<T>> {
template <typename T, typename E>
struct TypeConverter<Array<T>, std::set<E>> {
static Array<T> Convert(const std::set<E>& input) {
- Array<T> result(0u);
+ Array<T> result = Array<T>::New(0u);
for (auto i : input)
result.push_back(TypeConverter<T, E>::Convert(i));
return result.Pass();
« no previous file with comments | « mojo/dart/embedder/test/dart_to_cpp_tests.cc ('k') | mojo/public/cpp/bindings/lib/array_serialization.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698