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

Unified Diff: ui/events/mojo/latency_info_struct_traits.cc

Issue 2276743002: LatencyInfo mojo: Avoid extra copy of LatencyComponents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/mojo/latency_info_struct_traits.cc
diff --git a/ui/events/mojo/latency_info_struct_traits.cc b/ui/events/mojo/latency_info_struct_traits.cc
index 78705c2c16df602e03ef09aa395d44658c3a198a..63b01995049cc93792c5112249433985adad4c6d 100644
--- a/ui/events/mojo/latency_info_struct_traits.cc
+++ b/ui/events/mojo/latency_info_struct_traits.cc
@@ -276,12 +276,18 @@ bool StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo>::Read(
if (!data.ReadTraceName(&out->trace_name_))
return false;
- // TODO(fsamuel): Figure out how to optimize deserialization.
- mojo::Array<ui::mojom::LatencyComponentPairPtr> components;
- if (!data.ReadLatencyComponents(&components))
- return false;
- for (uint32_t i = 0; i < components.size(); ++i)
- out->latency_components_[components[i]->key] = components[i]->value;
+ mojo::ArrayDataView<ui::mojom::LatencyComponentPairDataView> components;
+ data.GetLatencyComponentsDataView(&components);
+ for (uint32_t i = 0; i < components.size(); ++i) {
+ ui::mojom::LatencyComponentPairDataView component_pair;
+ components.GetDataView(i, &component_pair);
yzshen1 2016/08/23 21:23:05 This change itself LGTM. Performance fyi: It woul
+ ui::LatencyInfo::LatencyMap::key_type key;
+ if (!component_pair.ReadKey(&key))
+ return false;
+ auto& value = out->latency_components_[key];
+ if (!component_pair.ReadValue(&value))
+ return false;
+ }
InputCoordinateArray input_coordinate_array = {
0, ui::LatencyInfo::kMaxInputCoordinates, out->input_coordinates_};
« 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