aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google
diff options
context:
space:
mode:
authorGravatar Chris Kennelly <ckennelly@google.com>2017-02-07 17:41:16 -0800
committerGravatar Chris Kennelly <ckennelly@google.com>2017-02-07 17:41:16 -0800
commit56da82820ecfff29166efd006d26935d9f3d2149 (patch)
tree5cdb3cfcdb0ed2e643c1d98b1f25c6ebaaa157f5 /src/google
parentc00274313d03a0a7f10e8f6473541faf3739353b (diff)
Avoid aliasing CodedInputStream::buffer_ when parsing little endian integers.
This eliminates an unnecessary reload of buffer_ that occurs (before this change) after the store to *value.
Diffstat (limited to 'src/google')
-rw-r--r--src/google/protobuf/io/coded_stream.h6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h
index 557312d3..399c6248 100644
--- a/src/google/protobuf/io/coded_stream.h
+++ b/src/google/protobuf/io/coded_stream.h
@@ -996,8 +996,7 @@ inline const uint8* CodedInputStream::ReadLittleEndian64FromArray(
inline bool CodedInputStream::ReadLittleEndian32(uint32* value) {
#if defined(PROTOBUF_LITTLE_ENDIAN)
if (GOOGLE_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {
- memcpy(value, buffer_, sizeof(*value));
- Advance(sizeof(*value));
+ buffer_ = ReadLittleEndian32FromArray(buffer_, value);
return true;
} else {
return ReadLittleEndian32Fallback(value);
@@ -1010,8 +1009,7 @@ inline bool CodedInputStream::ReadLittleEndian32(uint32* value) {
inline bool CodedInputStream::ReadLittleEndian64(uint64* value) {
#if defined(PROTOBUF_LITTLE_ENDIAN)
if (GOOGLE_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {
- memcpy(value, buffer_, sizeof(*value));
- Advance(sizeof(*value));
+ buffer_ = ReadLittleEndian64FromArray(buffer_, value);
return true;
} else {
return ReadLittleEndian64Fallback(value);