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

Unified Diff: components/packed_ct_ev_whitelist/bit_stream_reader.cc

Issue 1070903003: Optimize BitStreamReader, speed up EV Whitelist loading (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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/packed_ct_ev_whitelist/bit_stream_reader.cc
diff --git a/components/packed_ct_ev_whitelist/bit_stream_reader.cc b/components/packed_ct_ev_whitelist/bit_stream_reader.cc
index e4f6cc7b64a8896055bc56dd85f272d891b7f745..c0ebbbd0ec02bd222572fbb8ddbf07b1a0e3b160 100644
--- a/components/packed_ct_ev_whitelist/bit_stream_reader.cc
+++ b/components/packed_ct_ev_whitelist/bit_stream_reader.cc
@@ -7,7 +7,6 @@
#include "base/big_endian.h"
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
-
Ryan Sleevi 2015/04/09 01:33:57 Don't delete this newline
ian fette 2015/04/09 16:22:13 Done.
namespace packed_ct_ev_whitelist {
namespace internal {
@@ -34,8 +33,16 @@ bool BitStreamReader::ReadBits(uint8_t num_bits, uint64_t* out) {
return false;
*out = 0;
- for (uint8_t i = 0; i < num_bits; ++i)
- (*out) |= (static_cast<uint64_t>(ReadBit()) << (num_bits - (i + 1)));
+
+ for (; num_bits && (current_bit_ != 7); --num_bits)
+ (*out) |= (static_cast<uint64_t>(ReadBit() << (num_bits - 1)));
+ for (; num_bits / 8; num_bits -= 8) {
+ (*out) |= (static_cast<uint64_t>(source_.data()[current_byte_]) & 0xff)
+ << (num_bits - 8);
Ryan Sleevi 2015/04/09 01:33:57 I'm not terribly keen on this, which duplicates th
ian fette 2015/04/09 02:43:06 One important precondition is whether the stream i
Ryan Sleevi 2015/04/09 02:57:16 Right, I was just talking in the context of the se
ian fette 2015/04/09 16:22:13 Done.
+ current_byte_++;
+ }
+ for (; num_bits; --num_bits)
+ (*out) |= (static_cast<uint64_t>(ReadBit() << (num_bits - 1)));
return true;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698