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

Unified Diff: components/rappor/sample.cc

Issue 1112003002: Use 64 bit shift when convert uint64_t to ByteVector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restore the cast Created 5 years, 8 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_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/rappor/sample.cc
diff --git a/components/rappor/sample.cc b/components/rappor/sample.cc
index 6fbe615a5dc4cc0dde46dffe5b242858a08578fb..1aec6167da59eb037951e3b92536405e66e39048 100644
--- a/components/rappor/sample.cc
+++ b/components/rappor/sample.cc
@@ -56,14 +56,9 @@ void Sample::ExportMetrics(const std::string& secret,
uint64_t value = kv.second;
const auto it = sizes_.find(kv.first);
DCHECK(it != sizes_.end());
- uint64_t size = it->second;
+ size_t size = it->second;
ByteVector value_bytes(size);
- for (size_t i = 0; i < size; i++) {
- // Get the value of the i-th smallest byte and copy it to the byte vector.
- uint64_t shift = i * 8;
- uint64_t byte_mask = 0xff << shift;
- value_bytes[i] = (value & byte_mask) >> shift;
- }
+ Uint64ToByteVector(value, size, &value_bytes);
ByteVector report_bytes = internal::GenerateReport(
secret, parameters_, value_bytes);
« no previous file with comments | « components/rappor/byte_vector_utils_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698