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

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

Issue 2885223002: Protobuf: Remove protobuf globals patch (Closed)
Patch Set: typo Created 3 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
« no previous file with comments | « third_party/protobuf/src/google/protobuf/stubs/structurally_valid.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 return -1; 521 return -1;
522 522
523 dest[used] = '\0'; // doesn't count towards return value though 523 dest[used] = '\0'; // doesn't count towards return value though
524 return used; 524 return used;
525 } 525 }
526 526
527 // Calculates the length of the C-style escaped version of 'src'. 527 // Calculates the length of the C-style escaped version of 'src'.
528 // Assumes that non-printable characters are escaped using octal sequences, and 528 // Assumes that non-printable characters are escaped using octal sequences, and
529 // that UTF-8 bytes are not handled specially. 529 // that UTF-8 bytes are not handled specially.
530 static inline size_t CEscapedLength(StringPiece src) { 530 static inline size_t CEscapedLength(StringPiece src) {
531 static const char c_escaped_len[256] = { 531 static char c_escaped_len[256] = {
532 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 4, 4, 2, 4, 4, // \t, \n, \r 532 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 4, 4, 2, 4, 4, // \t, \n, \r
533 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 533 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
534 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, // ", ' 534 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, // ", '
535 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // '0'..'9' 535 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // '0'..'9'
536 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 'A'..'O' 536 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 'A'..'O'
537 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, // 'P'..'Z', '\' 537 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, // 'P'..'Z', '\'
538 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 'a'..'o' 538 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 'a'..'o'
539 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, // 'p'..'z', DEL 539 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, // 'p'..'z', DEL
540 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 540 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
541 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 541 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 } while (i > 0); 884 } while (i > 0);
885 *p = '-'; 885 *p = '-';
886 return p; 886 return p;
887 } 887 }
888 } 888 }
889 } 889 }
890 890
891 char *FastHexToBuffer(int i, char* buffer) { 891 char *FastHexToBuffer(int i, char* buffer) {
892 GOOGLE_CHECK(i >= 0) << "FastHexToBuffer() wants non-negative integers, not " << i; 892 GOOGLE_CHECK(i >= 0) << "FastHexToBuffer() wants non-negative integers, not " << i;
893 893
894 static const char hexdigits[] = "0123456789abcdef"; 894 static const char *hexdigits = "0123456789abcdef";
895 char *p = buffer + 21; 895 char *p = buffer + 21;
896 *p-- = '\0'; 896 *p-- = '\0';
897 do { 897 do {
898 *p-- = hexdigits[i & 15]; // mod by 16 898 *p-- = hexdigits[i & 15]; // mod by 16
899 i >>= 4; // divide by 16 899 i >>= 4; // divide by 16
900 } while (i > 0); 900 } while (i > 0);
901 return p + 1; 901 return p + 1;
902 } 902 }
903 903
904 char *InternalFastHexToBuffer(uint64 value, char* buffer, int num_byte) { 904 char *InternalFastHexToBuffer(uint64 value, char* buffer, int num_byte) {
905 static const char hexdigits[] = "0123456789abcdef"; 905 static const char *hexdigits = "0123456789abcdef";
906 buffer[num_byte] = '\0'; 906 buffer[num_byte] = '\0';
907 for (int i = num_byte - 1; i >= 0; i--) { 907 for (int i = num_byte - 1; i >= 0; i--) {
908 #ifdef _M_X64 908 #ifdef _M_X64
909 // MSVC x64 platform has a bug optimizing the uint32(value) in the #else 909 // MSVC x64 platform has a bug optimizing the uint32(value) in the #else
910 // block. Given that the uint32 cast was to improve performance on 32-bit 910 // block. Given that the uint32 cast was to improve performance on 32-bit
911 // platforms, we use 64-bit '&' directly. 911 // platforms, we use 64-bit '&' directly.
912 buffer[i] = hexdigits[value & 0xf]; 912 buffer[i] = hexdigits[value & 0xf];
913 #else 913 #else
914 buffer[i] = hexdigits[uint32(value) & 0xf]; 914 buffer[i] = hexdigits[uint32(value) & 0xf];
915 #endif 915 #endif
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after
2280 // Return length of a single UTF-8 source character 2280 // Return length of a single UTF-8 source character
2281 int UTF8FirstLetterNumBytes(const char* src, int len) { 2281 int UTF8FirstLetterNumBytes(const char* src, int len) {
2282 if (len == 0) { 2282 if (len == 0) {
2283 return 0; 2283 return 0;
2284 } 2284 }
2285 return kUTF8LenTbl[*reinterpret_cast<const uint8*>(src)]; 2285 return kUTF8LenTbl[*reinterpret_cast<const uint8*>(src)];
2286 } 2286 }
2287 2287
2288 } // namespace protobuf 2288 } // namespace protobuf
2289 } // namespace google 2289 } // namespace google
OLDNEW
« no previous file with comments | « third_party/protobuf/src/google/protobuf/stubs/structurally_valid.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698