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

Unified Diff: net/interfaces/ip_address_struct_traits.h

Issue 2881673002: Avoid heap allocations in IPAddress (Closed)
Patch Set: New constructor 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
« no previous file with comments | « net/dns/mojo_host_struct_traits.cc ('k') | net/interfaces/ip_address_struct_traits.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/interfaces/ip_address_struct_traits.h
diff --git a/net/interfaces/ip_address_struct_traits.h b/net/interfaces/ip_address_struct_traits.h
index 9c97baf8f6f11a02510769c9a406bb364d51f48a..9c7b48e0d4997f0fb093aaaffa4ed41537d8343f 100644
--- a/net/interfaces/ip_address_struct_traits.h
+++ b/net/interfaces/ip_address_struct_traits.h
@@ -12,8 +12,9 @@
namespace mojo {
template <>
struct StructTraits<net::interfaces::IPAddressDataView, net::IPAddress> {
- static const std::vector<uint8_t>& address(const net::IPAddress& ip_address) {
- return ip_address.bytes();
+ static const std::vector<uint8_t> address(const net::IPAddress& ip_address) {
+ // TODO(rch): avoid creating a vector here.
+ return ip_address.CopyBytesToVector();
}
static bool Read(net::interfaces::IPAddressDataView obj, net::IPAddress* out);
« no previous file with comments | « net/dns/mojo_host_struct_traits.cc ('k') | net/interfaces/ip_address_struct_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698