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

Unified Diff: components/rappor/reports.cc

Issue 2156383002: Avoid some string copies in RAPPOR code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « components/rappor/byte_vector_utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/rappor/reports.cc
diff --git a/components/rappor/reports.cc b/components/rappor/reports.cc
index 45d73b693e3c9df2ed60354493f0c67c32dba0f6..2f0f13206d2ee65e7daf13b2ac39e8da0bd145ad 100644
--- a/components/rappor/reports.cc
+++ b/components/rappor/reports.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "base/rand_util.h"
+#include "base/strings/string_piece.h"
#include "components/rappor/byte_vector_utils.h"
#include "components/rappor/rappor_parameters.h"
@@ -20,8 +21,8 @@ ByteVector GenerateReport(const std::string& secret,
// client's secret key + real data as a seed. The inclusion of the secret
// in the seed avoids correlations between real and fake data.
// The seed isn't a human-readable string.
- const std::string personalization_string =
- std::string(value.begin(), value.end());
+ const base::StringPiece personalization_string(
+ reinterpret_cast<const char*>(&value[0]), value.size());
HmacByteVectorGenerator hmac_generator(value.size(), secret,
personalization_string);
const ByteVector fake_mask =
« no previous file with comments | « components/rappor/byte_vector_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698