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

Side by Side Diff: components/sync/base/ordinal.h

Issue 2768923004: Remove redundant DCHECKs (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | net/spdy/spdy_protocol.h » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef COMPONENTS_SYNC_BASE_ORDINAL_H_ 5 #ifndef COMPONENTS_SYNC_BASE_ORDINAL_H_
6 #define COMPONENTS_SYNC_BASE_ORDINAL_H_ 6 #define COMPONENTS_SYNC_BASE_ORDINAL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 398
399 template <typename Traits> 399 template <typename Traits>
400 int Ordinal<Traits>::GetDigitValue(const std::string& bytes, size_t i) { 400 int Ordinal<Traits>::GetDigitValue(const std::string& bytes, size_t i) {
401 return GetDigit(bytes, i) - kZeroDigit; 401 return GetDigit(bytes, i) - kZeroDigit;
402 } 402 }
403 403
404 template <typename Traits> 404 template <typename Traits>
405 int Ordinal<Traits>::AddDigitValue(std::string* bytes, 405 int Ordinal<Traits>::AddDigitValue(std::string* bytes,
406 size_t i, 406 size_t i,
407 int digit_value) { 407 int digit_value) {
408 DCHECK_GE(i, 0U);
409 DCHECK_LT(i, bytes->length()); 408 DCHECK_LT(i, bytes->length());
410 409
411 for (int j = static_cast<int>(i); j >= 0 && digit_value > 0; --j) { 410 for (int j = static_cast<int>(i); j >= 0 && digit_value > 0; --j) {
412 int byte_j_value = GetDigitValue(*bytes, j) + digit_value; 411 int byte_j_value = GetDigitValue(*bytes, j) + digit_value;
413 digit_value = byte_j_value / kRadix; 412 digit_value = byte_j_value / kRadix;
414 DCHECK_LE(digit_value, 1); 413 DCHECK_LE(digit_value, 1);
415 byte_j_value %= kRadix; 414 byte_j_value %= kRadix;
416 (*bytes)[j] = static_cast<char>(kZeroDigit + byte_j_value); 415 (*bytes)[j] = static_cast<char>(kZeroDigit + byte_j_value);
417 } 416 }
418 return digit_value; 417 return digit_value;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 DCHECK_LT(midpoint, end_bytes); 482 DCHECK_LT(midpoint, end_bytes);
484 483
485 Ordinal<Traits> midpoint_ordinal(midpoint); 484 Ordinal<Traits> midpoint_ordinal(midpoint);
486 DCHECK(midpoint_ordinal.IsValid()); 485 DCHECK(midpoint_ordinal.IsValid());
487 return midpoint_ordinal; 486 return midpoint_ordinal;
488 } 487 }
489 488
490 } // namespace syncer 489 } // namespace syncer
491 490
492 #endif // COMPONENTS_SYNC_BASE_ORDINAL_H_ 491 #endif // COMPONENTS_SYNC_BASE_ORDINAL_H_
OLDNEW
« no previous file with comments | « no previous file | net/spdy/spdy_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698