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

Unified Diff: ppapi/shared_impl/private/net_address_private_impl.cc

Issue 2881673002: Avoid heap allocations in IPAddress (Closed)
Patch Set: Address comments 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: ppapi/shared_impl/private/net_address_private_impl.cc
diff --git a/ppapi/shared_impl/private/net_address_private_impl.cc b/ppapi/shared_impl/private/net_address_private_impl.cc
index d410d8f28dbe7286b1e5b78391c2a2db00623dd5..b259c7e2e78427b07d03d08dbdd1d46edeb3c1cf 100644
--- a/ppapi/shared_impl/private/net_address_private_impl.cc
+++ b/ppapi/shared_impl/private/net_address_private_impl.cc
@@ -451,7 +451,7 @@ bool NetAddressPrivateImpl::SockaddrToNetAddress(
// static
bool NetAddressPrivateImpl::IPEndPointToNetAddress(
- const std::vector<uint8_t>& address,
+ const net::IPAddress::IPAddressBytes& address,
uint16_t port,
PP_NetAddress_Private* addr) {
if (!addr)
@@ -484,7 +484,7 @@ bool NetAddressPrivateImpl::IPEndPointToNetAddress(
// static
bool NetAddressPrivateImpl::NetAddressToIPEndPoint(
const PP_NetAddress_Private& addr,
- std::vector<uint8_t>* address,
+ net::IPAddress::IPAddressBytes* address,
uint16_t* port) {
if (!address || !port)
return false;
@@ -494,9 +494,8 @@ bool NetAddressPrivateImpl::NetAddressToIPEndPoint(
return false;
*port = net_addr->port;
- size_t address_size = GetAddressSize(net_addr);
- address->assign(&net_addr->address[0], &net_addr->address[address_size]);
-
+ for (uint8_t byte : net_addr->address)
+ address->push_back(byte);
return true;
}
#endif // !defined(OS_NACL)

Powered by Google App Engine
This is Rietveld 408576698