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

Side by Side Diff: base/i18n/streaming_utf8_validator.cc

Issue 189603007: Let DCHECK in non-official-release build be opt-in with dcheck_always_on=1 only (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // This implementation doesn't use ICU. The ICU macros are oriented towards 5 // This implementation doesn't use ICU. The ICU macros are oriented towards
6 // character-at-a-time processing, whereas byte-at-a-time processing is easier 6 // character-at-a-time processing, whereas byte-at-a-time processing is easier
7 // with streaming input. 7 // with streaming input.
8 8
9 #include "base/i18n/streaming_utf8_validator.h" 9 #include "base/i18n/streaming_utf8_validator.h"
10 10
11 #include "base/i18n/utf8_validator_tables.h" 11 #include "base/i18n/utf8_validator_tables.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 13
14 namespace base { 14 namespace base {
15 namespace { 15 namespace {
16 16
17 uint8 StateTableLookup(uint8 offset) { 17 uint8 StateTableLookup(uint8 offset) {
18 // Skip the bounds check on non-debug builds so that it isn't necessary to set 18 // Skip the bounds check on non-debug builds.
19 // LOGGING_IS_OFFICIAL_BUILD just to do a performance test.
20 if (logging::DEBUG_MODE) 19 if (logging::DEBUG_MODE)
Xianzhu 2014/03/07 22:40:38 I'm not sure about this. The original intent was t
Nico 2014/03/07 22:58:35 I think so.
Xianzhu 2014/03/07 23:29:36 Removed the check.
21 DCHECK_LT(offset, internal::kUtf8ValidatorTablesSize); 20 DCHECK_LT(offset, internal::kUtf8ValidatorTablesSize);
22 return internal::kUtf8ValidatorTables[offset]; 21 return internal::kUtf8ValidatorTables[offset];
23 } 22 }
24 23
25 } // namespace 24 } // namespace
26 25
27 StreamingUtf8Validator::State StreamingUtf8Validator::AddBytes(const char* data, 26 StreamingUtf8Validator::State StreamingUtf8Validator::AddBytes(const char* data,
28 size_t size) { 27 size_t size) {
29 // Copy |state_| into a local variable so that the compiler doesn't have to be 28 // Copy |state_| into a local variable so that the compiler doesn't have to be
30 // careful of aliasing. 29 // careful of aliasing.
(...skipping 22 matching lines...) Expand all
53 void StreamingUtf8Validator::Reset() { 52 void StreamingUtf8Validator::Reset() {
54 state_ = 0u; 53 state_ = 0u;
55 } 54 }
56 55
57 bool StreamingUtf8Validator::Validate(const std::string& string) { 56 bool StreamingUtf8Validator::Validate(const std::string& string) {
58 return StreamingUtf8Validator().AddBytes(string.data(), string.size()) == 57 return StreamingUtf8Validator().AddBytes(string.data(), string.size()) ==
59 VALID_ENDPOINT; 58 VALID_ENDPOINT;
60 } 59 }
61 60
62 } // namespace base 61 } // namespace base
OLDNEW
« no previous file with comments | « base/base_switches.cc ('k') | base/logging.h » ('j') | base/logging_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698