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

Unified Diff: net/interfaces/ip_address_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/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..91b2024e8a9ef09fd14c9709302ce885fea76d99 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) {
+ return std::vector<uint8_t>(ip_address.bytes().begin(),
eroman 2017/05/12 23:25:05 Ditto.
Ryan Hamilton 2017/05/13 13:20:47 Done.
+ ip_address.bytes().end());
}
static bool Read(net::interfaces::IPAddressDataView obj, net::IPAddress* out);

Powered by Google App Engine
This is Rietveld 408576698