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

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

Issue 2881673002: Avoid heap allocations in IPAddress (Closed)
Patch Set: Done 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..43ffbe4a02d57e83e837d31dc45f232bab3cca04 100644
--- a/ppapi/shared_impl/private/net_address_private_impl.cc
+++ b/ppapi/shared_impl/private/net_address_private_impl.cc
@@ -9,6 +9,7 @@
#include <string>
+#include "base/containers/stack_container.h"
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
@@ -451,7 +452,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 +485,7 @@ bool NetAddressPrivateImpl::IPEndPointToNetAddress(
// static
bool NetAddressPrivateImpl::NetAddressToIPEndPoint(
const PP_NetAddress_Private& addr,
- std::vector<uint8_t>* address,
+ base::StackVector<uint8_t, 16>* address,
uint16_t* port) {
if (!address || !port)
return false;
@@ -495,7 +496,8 @@ bool NetAddressPrivateImpl::NetAddressToIPEndPoint(
*port = net_addr->port;
size_t address_size = GetAddressSize(net_addr);
- address->assign(&net_addr->address[0], &net_addr->address[address_size]);
+ address->container().assign(&net_addr->address[0],
+ &net_addr->address[address_size]);
eroman 2017/05/19 22:00:07 Technically this existing code was relying on unde
Ryan Hamilton 2017/05/20 03:21:44 As per your previous comment, I switched this to t
eroman 2017/05/22 18:06:44 This translation presumes that |address| is the em
Ryan Hamilton 2017/05/22 22:12:32 Done.
return true;
}

Powered by Google App Engine
This is Rietveld 408576698