OLD | NEW |
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 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 {'6','5'}, {'6','6'}, {'6','7'}, {'6','8'}, {'6','9'}, | 959 {'6','5'}, {'6','6'}, {'6','7'}, {'6','8'}, {'6','9'}, |
960 {'7','0'}, {'7','1'}, {'7','2'}, {'7','3'}, {'7','4'}, | 960 {'7','0'}, {'7','1'}, {'7','2'}, {'7','3'}, {'7','4'}, |
961 {'7','5'}, {'7','6'}, {'7','7'}, {'7','8'}, {'7','9'}, | 961 {'7','5'}, {'7','6'}, {'7','7'}, {'7','8'}, {'7','9'}, |
962 {'8','0'}, {'8','1'}, {'8','2'}, {'8','3'}, {'8','4'}, | 962 {'8','0'}, {'8','1'}, {'8','2'}, {'8','3'}, {'8','4'}, |
963 {'8','5'}, {'8','6'}, {'8','7'}, {'8','8'}, {'8','9'}, | 963 {'8','5'}, {'8','6'}, {'8','7'}, {'8','8'}, {'8','9'}, |
964 {'9','0'}, {'9','1'}, {'9','2'}, {'9','3'}, {'9','4'}, | 964 {'9','0'}, {'9','1'}, {'9','2'}, {'9','3'}, {'9','4'}, |
965 {'9','5'}, {'9','6'}, {'9','7'}, {'9','8'}, {'9','9'} | 965 {'9','5'}, {'9','6'}, {'9','7'}, {'9','8'}, {'9','9'} |
966 }; | 966 }; |
967 | 967 |
968 char* FastUInt32ToBufferLeft(uint32 u, char* buffer) { | 968 char* FastUInt32ToBufferLeft(uint32 u, char* buffer) { |
969 int digits; | 969 uint32 digits; |
970 const char *ASCII_digits = NULL; | 970 const char *ASCII_digits = NULL; |
971 // 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 |
972 // as possible by using multiplication and subtraction rather than mod (%), | 972 // as possible by using multiplication and subtraction rather than mod (%), |
973 // and by outputting two digits at a time rather than one. | 973 // 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 | 974 // 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 | 975 // that case in one branch-free block of code, and only output conditional |
976 // branches into it from below. | 976 // branches into it from below. |
977 if (u >= 1000000000) { // >= 1,000,000,000 | 977 if (u >= 1000000000) { // >= 1,000,000,000 |
978 digits = u / 100000000; // 100,000,000 | 978 digits = u / 100000000; // 100,000,000 |
979 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 Loading... |
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 |
OLD | NEW |