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

Side by Side Diff: base/string_util.cc

Issue 10035042: Rewrite base::JSONReader to be 35-40% faster, depending on the input string. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Really fix Windows, address comments Created 8 years, 7 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
« no previous file with comments | « base/json/json_reader_unittest.cc ('k') | base/values.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 #include "base/string_util.h" 5 #include "base/string_util.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include <ctype.h> 9 #include <ctype.h>
10 #include <errno.h> 10 #include <errno.h>
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 469
470 bool IsStringUTF8(const std::string& str) { 470 bool IsStringUTF8(const std::string& str) {
471 const char *src = str.data(); 471 const char *src = str.data();
472 int32 src_len = static_cast<int32>(str.length()); 472 int32 src_len = static_cast<int32>(str.length());
473 int32 char_index = 0; 473 int32 char_index = 0;
474 474
475 while (char_index < src_len) { 475 while (char_index < src_len) {
476 int32 code_point; 476 int32 code_point;
477 CBU8_NEXT(src, char_index, src_len, code_point); 477 CBU8_NEXT(src, char_index, src_len, code_point);
478 if (!base::IsValidCharacter(code_point)) 478 if (!base::IsValidCharacter(code_point))
479 return false; 479 return false;
480 } 480 }
481 return true; 481 return true;
482 } 482 }
483 483
484 template<typename Iter> 484 template<typename Iter>
485 static inline bool DoLowerCaseEqualsASCII(Iter a_begin, 485 static inline bool DoLowerCaseEqualsASCII(Iter a_begin,
486 Iter a_end, 486 Iter a_end,
487 const char* b) { 487 const char* b) {
488 for (Iter it = a_begin; it != a_end; ++it, ++b) { 488 for (Iter it = a_begin; it != a_end; ++it, ++b) {
489 if (!*b || base::ToLowerASCII(*it) != *b) 489 if (!*b || base::ToLowerASCII(*it) != *b)
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 } 1046 }
1047 1047
1048 } // namespace 1048 } // namespace
1049 1049
1050 size_t base::strlcpy(char* dst, const char* src, size_t dst_size) { 1050 size_t base::strlcpy(char* dst, const char* src, size_t dst_size) {
1051 return lcpyT<char>(dst, src, dst_size); 1051 return lcpyT<char>(dst, src, dst_size);
1052 } 1052 }
1053 size_t base::wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size) { 1053 size_t base::wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size) {
1054 return lcpyT<wchar_t>(dst, src, dst_size); 1054 return lcpyT<wchar_t>(dst, src, dst_size);
1055 } 1055 }
OLDNEW
« no previous file with comments | « base/json/json_reader_unittest.cc ('k') | base/values.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698