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

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

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/i18n/streaming_utf8_validator_perftest.cc ('k') | base/strings/string_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 // This file defines utility functions for working with strings. 5 // This file defines utility functions for working with strings.
6 6
7 #ifndef BASE_STRINGS_STRING_UTIL_H_ 7 #ifndef BASE_STRINGS_STRING_UTIL_H_
8 #define BASE_STRINGS_STRING_UTIL_H_ 8 #define BASE_STRINGS_STRING_UTIL_H_
9 9
10 #include <ctype.h> 10 #include <ctype.h>
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 // 241 //
242 // Note that IsStringUTF8 checks not only if the input is structurally 242 // Note that IsStringUTF8 checks not only if the input is structurally
243 // valid but also if it doesn't contain any non-character codepoint 243 // valid but also if it doesn't contain any non-character codepoint
244 // (e.g. U+FFFE). It's done on purpose because all the existing callers want 244 // (e.g. U+FFFE). It's done on purpose because all the existing callers want
245 // to have the maximum 'discriminating' power from other encodings. If 245 // to have the maximum 'discriminating' power from other encodings. If
246 // there's a use case for just checking the structural validity, we have to 246 // there's a use case for just checking the structural validity, we have to
247 // add a new function for that. 247 // add a new function for that.
248 // 248 //
249 // IsStringASCII assumes the input is likely all ASCII, and does not leave early 249 // IsStringASCII assumes the input is likely all ASCII, and does not leave early
250 // if it is not the case. 250 // if it is not the case.
251 BASE_EXPORT bool IsStringUTF8(const std::string& str); 251 BASE_EXPORT bool IsStringUTF8(const StringPiece& str);
252 BASE_EXPORT bool IsStringASCII(const StringPiece& str); 252 BASE_EXPORT bool IsStringASCII(const StringPiece& str);
253 BASE_EXPORT bool IsStringASCII(const StringPiece16& str); 253 BASE_EXPORT bool IsStringASCII(const StringPiece16& str);
254 // A convenience adaptor for WebStrings, as they don't convert into 254 // A convenience adaptor for WebStrings, as they don't convert into
255 // StringPieces directly. 255 // StringPieces directly.
256 BASE_EXPORT bool IsStringASCII(const string16& str); 256 BASE_EXPORT bool IsStringASCII(const string16& str);
257 #if defined(WCHAR_T_IS_UTF32) 257 #if defined(WCHAR_T_IS_UTF32)
258 BASE_EXPORT bool IsStringASCII(const std::wstring& str); 258 BASE_EXPORT bool IsStringASCII(const std::wstring& str);
259 #endif 259 #endif
260 260
261 // Converts the elements of the given string. This version uses a pointer to 261 // Converts the elements of the given string. This version uses a pointer to
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 #elif defined(WCHAR_T_IS_UTF32) 523 #elif defined(WCHAR_T_IS_UTF32)
524 typedef uint32 Unsigned; 524 typedef uint32 Unsigned;
525 #endif 525 #endif
526 }; 526 };
527 template<> 527 template<>
528 struct ToUnsigned<short> { 528 struct ToUnsigned<short> {
529 typedef unsigned short Unsigned; 529 typedef unsigned short Unsigned;
530 }; 530 };
531 531
532 #endif // BASE_STRINGS_STRING_UTIL_H_ 532 #endif // BASE_STRINGS_STRING_UTIL_H_
OLDNEW
« no previous file with comments | « base/i18n/streaming_utf8_validator_perftest.cc ('k') | base/strings/string_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698