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

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

Issue 2181443002: Mojo C++ bindings: make ipc/ mojom targets to use STL string/vector types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make further change to array_traits_stl.h to make MSan build happy. Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ipc/ipc_message_pipe_reader.cc ('k') | 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_traits_stl.h
diff --git a/mojo/public/cpp/bindings/array_traits_stl.h b/mojo/public/cpp/bindings/array_traits_stl.h
index 55efd32d29c9e5bf27908ae458b7149cafed13de..c1aac00a7cd4686091ed5be927bc5fd886c2d7c0 100644
--- a/mojo/public/cpp/bindings/array_traits_stl.h
+++ b/mojo/public/cpp/bindings/array_traits_stl.h
@@ -42,13 +42,17 @@ struct ArrayTraits<std::vector<T>> {
return input[index];
}
- static bool Resize(std::vector<T>& input, size_t size) {
+ static inline bool Resize(std::vector<T>& input, size_t size) {
+ // Instead of calling std::vector<T>::resize() directly, this is a hack to
+ // make compilers happy. Some compilers (e.g., Mac, Android, Linux MSan)
+ // currently don't allow resizing types like
+ // std::vector<std::vector<MoveOnlyType>>.
+ // Because the deserialization code doesn't care about the original contents
+ // of |input|, we discard them directly.
+ //
+ // The "inline" keyword of this method matters. Without it, we have observed
+ // significant perf regression with some tests on Mac. crbug.com/631415
if (input.size() != size) {
- // This is a hack to make compilers for Mac and Android happy. They
- // currently don't allow resizing types like
- // std::vector<std::vector<MoveOnlyType>>.
- // Because the deserialization code doesn't care about the original
- // contents of |input|, we discard them directly.
std::vector<T> temp(size);
input.swap(temp);
}
« no previous file with comments | « ipc/ipc_message_pipe_reader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698