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

Unified Diff: net/dns/mojo_host_struct_traits.h

Issue 2881673002: Avoid heap allocations in IPAddress (Closed)
Patch Set: More fixes Created 3 years, 7 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
Index: net/dns/mojo_host_struct_traits.h
diff --git a/net/dns/mojo_host_struct_traits.h b/net/dns/mojo_host_struct_traits.h
index 307e1b22ba8371aa75bb145abc95825e6270c523..bcd3dd0aceb5db61fb1ebdcc1c4f4869b0f976bf 100644
--- a/net/dns/mojo_host_struct_traits.h
+++ b/net/dns/mojo_host_struct_traits.h
@@ -50,8 +50,9 @@ struct StructTraits<net::interfaces::HostResolverRequestInfoDataView,
template <>
struct StructTraits<net::interfaces::IPEndPointDataView, net::IPEndPoint> {
- static const std::vector<uint8_t>& address(const net::IPEndPoint& obj) {
- return obj.address().bytes();
+ static const std::vector<uint8_t> address(const net::IPEndPoint& obj) {
+ return std::vector<uint8_t>(obj.address().bytes().begin(),
eroman 2017/05/12 23:25:05 .BytesAsVector() ? Although per earlier comment,
Ryan Hamilton 2017/05/13 13:20:47 Done.
eroman 2017/05/15 22:15:23 I don't know enough about mojo bindings to suggest
Ryan Hamilton 2017/05/17 18:26:41 rdsmith: do you know enough about mojo to help out
Randy Smith (Not in Mondays) 2017/05/17 18:53:58 This is getting into implementation guts, and I'd
eroman 2017/05/17 20:48:16 You could do say array<uint8, 16> Not sure how th
Randy Smith (Not in Mondays) 2017/05/17 20:52:54 I don't think mojo has a type that translates into
Ryan Hamilton 2017/05/17 23:14:04 It's worth keeping in mind that while the backing
yzshen1 2017/05/18 22:32:47 Sorry for missing this question. As Eric said, you
Ryan Hamilton 2017/05/19 03:38:49 I don't think that will work because sometimes the
yzshen1 2017/05/19 16:04:03 Please note that when I said array<uint8, 16>, it
+ obj.address().bytes().end());
}
static uint16_t port(const net::IPEndPoint& obj) { return obj.port(); }

Powered by Google App Engine
This is Rietveld 408576698