Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/tools/transport_security_state_generator/bit_writer.h" | 5 #include "net/tools/transport_security_state_generator/bit_writer.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace net { | 9 namespace net { |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 current_byte_ |= bit << (7 - used_); | 26 current_byte_ |= bit << (7 - used_); |
| 27 used_++; | 27 used_++; |
| 28 position_++; | 28 position_++; |
| 29 | 29 |
| 30 if (used_ == 8) { | 30 if (used_ == 8) { |
| 31 Flush(); | 31 Flush(); |
| 32 } | 32 } |
| 33 } | 33 } |
| 34 | 34 |
| 35 void BitWriter::Flush() { | 35 void BitWriter::Flush() { |
| 36 position_ += (8 - used_); | |
|
Ryan Sleevi
2017/02/14 20:53:17
This seems like a non-trivial behaviour change.
I
martijnc
2017/02/15 22:07:58
This doesn't change the API contract, both the old
| |
| 36 bytes_.push_back(current_byte_); | 37 bytes_.push_back(current_byte_); |
| 37 | 38 |
| 38 used_ = 0; | 39 used_ = 0; |
| 39 current_byte_ = 0; | 40 current_byte_ = 0; |
| 40 } | 41 } |
| 41 | 42 |
| 42 uint8_t BitWriter::BitLength(uint32_t input) const { | |
| 43 uint8_t number_of_bits = 0; | |
| 44 while (input != 0) { | |
| 45 number_of_bits++; | |
| 46 input >>= 1; | |
| 47 } | |
| 48 return number_of_bits; | |
| 49 } | |
| 50 | |
| 51 } // namespace transport_security_state | 43 } // namespace transport_security_state |
| 52 | 44 |
| 53 } // namespace net | 45 } // namespace net |
| OLD | NEW |