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

Side by Side Diff: net/dns/mojo_host_struct_traits.cc

Issue 2881673002: Avoid heap allocations in IPAddress (Closed)
Patch Set: Rename and Assign 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/dns/mojo_host_struct_traits.h" 5 #include "net/dns/mojo_host_struct_traits.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "net/base/address_list.h" 10 #include "net/base/address_list.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 70
71 // static 71 // static
72 bool StructTraits<net::interfaces::IPEndPointDataView, net::IPEndPoint>::Read( 72 bool StructTraits<net::interfaces::IPEndPointDataView, net::IPEndPoint>::Read(
73 net::interfaces::IPEndPointDataView data, 73 net::interfaces::IPEndPointDataView data,
74 net::IPEndPoint* out) { 74 net::IPEndPoint* out) {
75 std::vector<uint8_t> bytes; 75 std::vector<uint8_t> bytes;
76 if (!data.ReadAddress(&bytes)) 76 if (!data.ReadAddress(&bytes))
77 return false; 77 return false;
78 78
79 *out = net::IPEndPoint(net::IPAddress(bytes), data.port()); 79 *out =
80 net::IPEndPoint(net::IPAddress(bytes.data(), bytes.size()), data.port());
80 return true; 81 return true;
81 } 82 }
82 83
83 // static 84 // static
84 bool StructTraits<net::interfaces::AddressListDataView, net::AddressList>::Read( 85 bool StructTraits<net::interfaces::AddressListDataView, net::AddressList>::Read(
85 net::interfaces::AddressListDataView data, 86 net::interfaces::AddressListDataView data,
86 net::AddressList* out) { 87 net::AddressList* out) {
87 return data.ReadAddresses(&out->endpoints()); 88 return data.ReadAddresses(&out->endpoints());
88 } 89 }
89 90
90 } // namespace mojo 91 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698