diff options
author | liujisi@google.com <liujisi@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2011-07-05 21:05:40 +0000 |
---|---|---|
committer | liujisi@google.com <liujisi@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2011-07-05 21:05:40 +0000 |
commit | cb6dd4ef5f82e41e06179dcd57d3b1d9246ad6ac (patch) | |
tree | 72b3eca676416019595e07b45c7fc83cf217d65d | |
parent | 2a89d0022de803fe2dfd4832c4cb16d7ce99de84 (diff) | |
download | protobuf-cb6dd4ef5f82e41e06179dcd57d3b1d9246ad6ac.tar.gz protobuf-cb6dd4ef5f82e41e06179dcd57d3b1d9246ad6ac.tar.bz2 protobuf-cb6dd4ef5f82e41e06179dcd57d3b1d9246ad6ac.zip |
A workaround for MSVC 2010 x64 platform bug,
which affects proto compiler in generating field has_bit mask.
-rw-r--r-- | src/google/protobuf/stubs/strutil.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc index bb658ba8..ee07ce75 100644 --- a/src/google/protobuf/stubs/strutil.cc +++ b/src/google/protobuf/stubs/strutil.cc @@ -670,7 +670,14 @@ char *InternalFastHexToBuffer(uint64 value, char* buffer, int num_byte) { static const char *hexdigits = "0123456789abcdef"; buffer[num_byte] = '\0'; for (int i = num_byte - 1; i >= 0; i--) { +#ifdef _M_X64 + // MSVC x64 platform has a bug optimizing the uint32(value) in the #else + // block. Given that the uint32 cast was to improve performance on 32-bit + // platforms, we use 64-bit '&' directly. + buffer[i] = hexdigits[value & 0xf]; +#else buffer[i] = hexdigits[uint32(value) & 0xf]; +#endif value >>= 4; } return buffer; |