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

Side by Side Diff: net/quic/crypto/strike_register.cc

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 unified diff | Download patch
« no previous file with comments | « net/quic/crypto/source_address_token.cc ('k') | net/quic/quic_bandwidth.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/quic/crypto/strike_register.h" 5 #include "net/quic/crypto/strike_register.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 void SetOtherBits(uint8 otherbits) { 59 void SetOtherBits(uint8 otherbits) {
60 data_[1] = (data_[1] & 0xffffff00) | otherbits; 60 data_[1] = (data_[1] & 0xffffff00) | otherbits;
61 } 61 }
62 62
63 void SetNextPtr(uint32 next) { data_[0] = next; } 63 void SetNextPtr(uint32 next) { data_[0] = next; }
64 64
65 uint32 next() const { return data_[0]; } 65 uint32 next() const { return data_[0]; }
66 66
67 uint32 child(unsigned n) const { return data_[n] >> 8; } 67 uint32 child(unsigned n) const { return data_[n] >> 8; }
68 68
69 uint8 critbyte() const { return data_[0]; } 69 uint8 critbyte() const { return static_cast<uint8>(data_[0]); }
70 70
71 uint8 otherbits() const { return data_[1]; } 71 uint8 otherbits() const { return static_cast<uint8>(data_[1]); }
72 72
73 // These bytes are organised thus: 73 // These bytes are organised thus:
74 // <24 bits> left child 74 // <24 bits> left child
75 // <8 bits> crit-byte 75 // <8 bits> crit-byte
76 // <24 bits> right child 76 // <24 bits> right child
77 // <8 bits> other-bits 77 // <8 bits> other-bits
78 uint32 data_[2]; 78 uint32 data_[2];
79 }; 79 };
80 80
81 // kCreationTimeFromInternalEpoch contains the number of seconds between the 81 // kCreationTimeFromInternalEpoch contains the number of seconds between the
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 // If we just evicted the best match, then we have to try and match again. 187 // If we just evicted the best match, then we have to try and match again.
188 // We know that we didn't just empty the tree because we require that 188 // We know that we didn't just empty the tree because we require that
189 // max_entries_ >= 2. Also, we know that it doesn't match because, if it 189 // max_entries_ >= 2. Also, we know that it doesn't match because, if it
190 // did, it would have been returned previously. 190 // did, it would have been returned previously.
191 if (external_node_index == best_match_index) { 191 if (external_node_index == best_match_index) {
192 best_match_index = BestMatch(value); 192 best_match_index = BestMatch(value);
193 best_match = external_node(best_match_index); 193 best_match = external_node(best_match_index);
194 } 194 }
195 195
196 // Now we need to find the first bit where we differ from |best_match|. 196 // Now we need to find the first bit where we differ from |best_match|.
197 unsigned differing_byte; 197 uint8 differing_byte;
198 uint8 new_other_bits; 198 uint8 new_other_bits;
199 for (differing_byte = 0; differing_byte < sizeof(value); differing_byte++) { 199 for (differing_byte = 0; differing_byte < arraysize(value);
200 differing_byte++) {
200 new_other_bits = value[differing_byte] ^ best_match[differing_byte]; 201 new_other_bits = value[differing_byte] ^ best_match[differing_byte];
201 if (new_other_bits) { 202 if (new_other_bits) {
202 break; 203 break;
203 } 204 }
204 } 205 }
205 206
206 // Once we have the XOR the of first differing byte in new_other_bits we need 207 // Once we have the XOR the of first differing byte in new_other_bits we need
207 // to find the most significant differing bit. We could do this with a simple 208 // to find the most significant differing bit. We could do this with a simple
208 // for loop, testing bits 7..0. Instead we fold the bits so that we end up 209 // for loop, testing bits 7..0. Instead we fold the bits so that we end up
209 // with a byte where all the bits below the most significant one, are set. 210 // with a byte where all the bits below the most significant one, are set.
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 CHECK_EQ(free_internal_nodes.count(inter), 0u); 512 CHECK_EQ(free_internal_nodes.count(inter), 0u);
512 CHECK_EQ(used_internal_nodes->count(inter), 0u); 513 CHECK_EQ(used_internal_nodes->count(inter), 0u);
513 used_internal_nodes->insert(inter); 514 used_internal_nodes->insert(inter);
514 ValidateTree(inter, bit, bits, free_internal_nodes, free_external_nodes, 515 ValidateTree(inter, bit, bits, free_internal_nodes, free_external_nodes,
515 used_internal_nodes, used_external_nodes); 516 used_internal_nodes, used_external_nodes);
516 } 517 }
517 } 518 }
518 } 519 }
519 520
520 } // namespace net 521 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/source_address_token.cc ('k') | net/quic/quic_bandwidth.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698