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

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: 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
Index: components/rappor/sample.cc
diff --git a/components/rappor/sample.cc b/components/rappor/sample.cc
index 6fbe615a5dc4cc0dde46dffe5b242858a08578fb..0fce9f80fc46f9b503f7a137b9d1e2ebb0e3925e 100644
--- a/components/rappor/sample.cc
+++ b/components/rappor/sample.cc
@@ -58,12 +58,7 @@ void Sample::ExportMetrics(const std::string& secret,
DCHECK(it != sizes_.end());
uint64_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);
« components/rappor/byte_vector_utils.cc ('K') | « 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