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

Side by Side Diff: base/strings/string_util.cc

Issue 725443003: Avoid a string copy in URLRequestResourceBundleJob::GetData(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Tidy up Created 6 years, 1 month 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 | « base/strings/string_util.h ('k') | chrome/browser/extensions/chrome_url_request_util.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "base/strings/string_util.h" 5 #include "base/strings/string_util.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <math.h> 9 #include <math.h>
10 #include <stdarg.h> 10 #include <stdarg.h>
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 bool IsStringASCII(const string16& str) { 399 bool IsStringASCII(const string16& str) {
400 return DoIsStringASCII(str.data(), str.length()); 400 return DoIsStringASCII(str.data(), str.length());
401 } 401 }
402 402
403 #if defined(WCHAR_T_IS_UTF32) 403 #if defined(WCHAR_T_IS_UTF32)
404 bool IsStringASCII(const std::wstring& str) { 404 bool IsStringASCII(const std::wstring& str) {
405 return DoIsStringASCII(str.data(), str.length()); 405 return DoIsStringASCII(str.data(), str.length());
406 } 406 }
407 #endif 407 #endif
408 408
409 bool IsStringUTF8(const std::string& str) { 409 bool IsStringUTF8(const StringPiece& str) {
410 const char *src = str.data(); 410 const char *src = str.data();
411 int32 src_len = static_cast<int32>(str.length()); 411 int32 src_len = static_cast<int32>(str.length());
412 int32 char_index = 0; 412 int32 char_index = 0;
413 413
414 while (char_index < src_len) { 414 while (char_index < src_len) {
415 int32 code_point; 415 int32 code_point;
416 CBU8_NEXT(src, char_index, src_len, code_point); 416 CBU8_NEXT(src, char_index, src_len, code_point);
417 if (!IsValidCharacter(code_point)) 417 if (!IsValidCharacter(code_point))
418 return false; 418 return false;
419 } 419 }
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 } 949 }
950 950
951 } // namespace 951 } // namespace
952 952
953 size_t base::strlcpy(char* dst, const char* src, size_t dst_size) { 953 size_t base::strlcpy(char* dst, const char* src, size_t dst_size) {
954 return lcpyT<char>(dst, src, dst_size); 954 return lcpyT<char>(dst, src, dst_size);
955 } 955 }
956 size_t base::wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size) { 956 size_t base::wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size) {
957 return lcpyT<wchar_t>(dst, src, dst_size); 957 return lcpyT<wchar_t>(dst, src, dst_size);
958 } 958 }
OLDNEW
« no previous file with comments | « base/strings/string_util.h ('k') | chrome/browser/extensions/chrome_url_request_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698