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

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

Issue 2600753002: Reverts third_party/protobuf: Update to HEAD (f52e188fe4) (Closed)
Patch Set: Created 3 years, 12 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
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
111 void StripWhitespace(string* str) { 96 void StripWhitespace(string* str) {
112 int str_length = str->length(); 97 int str_length = str->length();
113 98
114 // Strip off leading whitespace. 99 // Strip off leading whitespace.
115 int first = 0; 100 int first = 0;
116 while (first < str_length && ascii_isspace(str->at(first))) { 101 while (first < str_length && ascii_isspace(str->at(first))) {
117 ++first; 102 ++first;
118 } 103 }
119 // If entire string is white space. 104 // If entire string is white space.
120 if (first == str_length) { 105 if (first == str_length) {
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 {'6','5'}, {'6','6'}, {'6','7'}, {'6','8'}, {'6','9'}, 959 {'6','5'}, {'6','6'}, {'6','7'}, {'6','8'}, {'6','9'},
975 {'7','0'}, {'7','1'}, {'7','2'}, {'7','3'}, {'7','4'}, 960 {'7','0'}, {'7','1'}, {'7','2'}, {'7','3'}, {'7','4'},
976 {'7','5'}, {'7','6'}, {'7','7'}, {'7','8'}, {'7','9'}, 961 {'7','5'}, {'7','6'}, {'7','7'}, {'7','8'}, {'7','9'},
977 {'8','0'}, {'8','1'}, {'8','2'}, {'8','3'}, {'8','4'}, 962 {'8','0'}, {'8','1'}, {'8','2'}, {'8','3'}, {'8','4'},
978 {'8','5'}, {'8','6'}, {'8','7'}, {'8','8'}, {'8','9'}, 963 {'8','5'}, {'8','6'}, {'8','7'}, {'8','8'}, {'8','9'},
979 {'9','0'}, {'9','1'}, {'9','2'}, {'9','3'}, {'9','4'}, 964 {'9','0'}, {'9','1'}, {'9','2'}, {'9','3'}, {'9','4'},
980 {'9','5'}, {'9','6'}, {'9','7'}, {'9','8'}, {'9','9'} 965 {'9','5'}, {'9','6'}, {'9','7'}, {'9','8'}, {'9','9'}
981 }; 966 };
982 967
983 char* FastUInt32ToBufferLeft(uint32 u, char* buffer) { 968 char* FastUInt32ToBufferLeft(uint32 u, char* buffer) {
984 uint32 digits; 969 int digits;
985 const char *ASCII_digits = NULL; 970 const char *ASCII_digits = NULL;
986 // The idea of this implementation is to trim the number of divides to as few 971 // The idea of this implementation is to trim the number of divides to as few
987 // as possible by using multiplication and subtraction rather than mod (%), 972 // as possible by using multiplication and subtraction rather than mod (%),
988 // and by outputting two digits at a time rather than one. 973 // and by outputting two digits at a time rather than one.
989 // The huge-number case is first, in the hopes that the compiler will output 974 // The huge-number case is first, in the hopes that the compiler will output
990 // that case in one branch-free block of code, and only output conditional 975 // that case in one branch-free block of code, and only output conditional
991 // branches into it from below. 976 // branches into it from below.
992 if (u >= 1000000000) { // >= 1,000,000,000 977 if (u >= 1000000000) { // >= 1,000,000,000
993 digits = u / 100000000; // 100,000,000 978 digits = u / 100000000; // 100,000,000
994 ASCII_digits = two_ASCII_digits[digits]; 979 ASCII_digits = two_ASCII_digits[digits];
(...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after
2295 // Return length of a single UTF-8 source character 2280 // Return length of a single UTF-8 source character
2296 int UTF8FirstLetterNumBytes(const char* src, int len) { 2281 int UTF8FirstLetterNumBytes(const char* src, int len) {
2297 if (len == 0) { 2282 if (len == 0) {
2298 return 0; 2283 return 0;
2299 } 2284 }
2300 return kUTF8LenTbl[*reinterpret_cast<const uint8*>(src)]; 2285 return kUTF8LenTbl[*reinterpret_cast<const uint8*>(src)];
2301 } 2286 }
2302 2287
2303 } // namespace protobuf 2288 } // namespace protobuf
2304 } // namespace google 2289 } // 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