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

Side by Side Diff: third_party/protobuf/src/google/protobuf/stubs/strutil.cc

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component Created 4 years 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
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved. 2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/ 3 // https://developers.google.com/protocol-buffers/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 void StripString(string* s, const char* remove, char replacewith) { 86 void StripString(string* s, const char* remove, char replacewith) {
87 const char * str_start = s->c_str(); 87 const char * str_start = s->c_str();
88 const char * str = str_start; 88 const char * str = str_start;
89 for (str = strpbrk(str, remove); 89 for (str = strpbrk(str, remove);
90 str != NULL; 90 str != NULL;
91 str = strpbrk(str + 1, remove)) { 91 str = strpbrk(str + 1, remove)) {
92 (*s)[str - str_start] = replacewith; 92 (*s)[str - str_start] = replacewith;
93 } 93 }
94 } 94 }
95 95
96 // ----------------------------------------------------------------------
97 // ReplaceCharacters
98 // Replaces any occurrence of the character 'remove' (or the characters
99 // in 'remove') with the character 'replacewith'.
100 // ----------------------------------------------------------------------
101 void ReplaceCharacters(string *s, const char *remove, char replacewith) {
102 const char *str_start = s->c_str();
103 const char *str = str_start;
104 for (str = strpbrk(str, remove);
105 str != NULL;
106 str = strpbrk(str + 1, remove)) {
107 (*s)[str - str_start] = replacewith;
108 }
109 }
110
96 void StripWhitespace(string* str) { 111 void StripWhitespace(string* str) {
97 int str_length = str->length(); 112 int str_length = str->length();
98 113
99 // Strip off leading whitespace. 114 // Strip off leading whitespace.
100 int first = 0; 115 int first = 0;
101 while (first < str_length && ascii_isspace(str->at(first))) { 116 while (first < str_length && ascii_isspace(str->at(first))) {
102 ++first; 117 ++first;
103 } 118 }
104 // If entire string is white space. 119 // If entire string is white space.
105 if (first == str_length) { 120 if (first == str_length) {
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 {'6','5'}, {'6','6'}, {'6','7'}, {'6','8'}, {'6','9'}, 974 {'6','5'}, {'6','6'}, {'6','7'}, {'6','8'}, {'6','9'},
960 {'7','0'}, {'7','1'}, {'7','2'}, {'7','3'}, {'7','4'}, 975 {'7','0'}, {'7','1'}, {'7','2'}, {'7','3'}, {'7','4'},
961 {'7','5'}, {'7','6'}, {'7','7'}, {'7','8'}, {'7','9'}, 976 {'7','5'}, {'7','6'}, {'7','7'}, {'7','8'}, {'7','9'},
962 {'8','0'}, {'8','1'}, {'8','2'}, {'8','3'}, {'8','4'}, 977 {'8','0'}, {'8','1'}, {'8','2'}, {'8','3'}, {'8','4'},
963 {'8','5'}, {'8','6'}, {'8','7'}, {'8','8'}, {'8','9'}, 978 {'8','5'}, {'8','6'}, {'8','7'}, {'8','8'}, {'8','9'},
964 {'9','0'}, {'9','1'}, {'9','2'}, {'9','3'}, {'9','4'}, 979 {'9','0'}, {'9','1'}, {'9','2'}, {'9','3'}, {'9','4'},
965 {'9','5'}, {'9','6'}, {'9','7'}, {'9','8'}, {'9','9'} 980 {'9','5'}, {'9','6'}, {'9','7'}, {'9','8'}, {'9','9'}
966 }; 981 };
967 982
968 char* FastUInt32ToBufferLeft(uint32 u, char* buffer) { 983 char* FastUInt32ToBufferLeft(uint32 u, char* buffer) {
969 int digits; 984 uint32 digits;
970 const char *ASCII_digits = NULL; 985 const char *ASCII_digits = NULL;
971 // The idea of this implementation is to trim the number of divides to as few 986 // The idea of this implementation is to trim the number of divides to as few
972 // as possible by using multiplication and subtraction rather than mod (%), 987 // as possible by using multiplication and subtraction rather than mod (%),
973 // and by outputting two digits at a time rather than one. 988 // and by outputting two digits at a time rather than one.
974 // The huge-number case is first, in the hopes that the compiler will output 989 // The huge-number case is first, in the hopes that the compiler will output
975 // that case in one branch-free block of code, and only output conditional 990 // that case in one branch-free block of code, and only output conditional
976 // branches into it from below. 991 // branches into it from below.
977 if (u >= 1000000000) { // >= 1,000,000,000 992 if (u >= 1000000000) { // >= 1,000,000,000
978 digits = u / 100000000; // 100,000,000 993 digits = u / 100000000; // 100,000,000
979 ASCII_digits = two_ASCII_digits[digits]; 994 ASCII_digits = two_ASCII_digits[digits];
(...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after
2280 // Return length of a single UTF-8 source character 2295 // Return length of a single UTF-8 source character
2281 int UTF8FirstLetterNumBytes(const char* src, int len) { 2296 int UTF8FirstLetterNumBytes(const char* src, int len) {
2282 if (len == 0) { 2297 if (len == 0) {
2283 return 0; 2298 return 0;
2284 } 2299 }
2285 return kUTF8LenTbl[*reinterpret_cast<const uint8*>(src)]; 2300 return kUTF8LenTbl[*reinterpret_cast<const uint8*>(src)];
2286 } 2301 }
2287 2302
2288 } // namespace protobuf 2303 } // namespace protobuf
2289 } // namespace google 2304 } // namespace google
OLDNEW
« no previous file with comments | « third_party/protobuf/src/google/protobuf/stubs/strutil.h ('k') | third_party/protobuf/src/google/protobuf/stubs/substitute.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698