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

Unified Diff: chrome/browser/media/webrtc/webrtc_text_log_handler.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
« no previous file with comments | « no previous file | content/browser/renderer_host/pepper/pepper_socket_utils.cc » ('j') | net/base/ip_address.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/media/webrtc/webrtc_text_log_handler.cc
diff --git a/chrome/browser/media/webrtc/webrtc_text_log_handler.cc b/chrome/browser/media/webrtc/webrtc_text_log_handler.cc
index ca36e00b46a32404fd3a64d45bebcc2bc4ee175d..1862133c909eb5295cd05c732bb09d914388f71e 100644
--- a/chrome/browser/media/webrtc/webrtc_text_log_handler.cc
+++ b/chrome/browser/media/webrtc/webrtc_text_log_handler.cc
@@ -10,6 +10,7 @@
#include <vector>
#include "base/bind.h"
+#include "base/containers/stack_container.h"
#include "base/cpu.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
@@ -77,9 +78,11 @@ std::string IPAddressToSensitiveString(const net::IPAddress& address) {
case net::IPAddress::kIPv6AddressSize: {
// TODO(grunell): Create a string of format "1:2:3:x:x:x:x:x" to clarify
// that the end has been stripped out.
- std::vector<uint8_t> bytes = address.bytes();
- std::fill(bytes.begin() + 6, bytes.end(), 0);
- net::IPAddress stripped_address(bytes);
+ base::StackVector<uint8_t, 16> bytes;
eroman 2017/05/19 22:00:07 How about without StackVector: net::IPAddressByte
Ryan Hamilton 2017/05/20 03:21:44 Done. (With minor modifications)
eroman 2017/05/22 18:06:44 Let's worry about that later (Was just an observat
+ for (uint8_t byte : address.bytes())
+ bytes->push_back(byte);
+ std::fill(bytes->begin() + 6, bytes->end(), 0);
+ net::IPAddress stripped_address(bytes->data(), bytes->size());
sensitive_address = stripped_address.ToString();
break;
}
« no previous file with comments | « no previous file | content/browser/renderer_host/pepper/pepper_socket_utils.cc » ('j') | net/base/ip_address.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698