aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/wire_format_lite.cc
diff options
context:
space:
mode:
authorGravatar Feng Xiao <xfxyjwf@gmail.com>2014-11-10 17:34:54 -0800
committerGravatar Feng Xiao <xfxyjwf@gmail.com>2014-11-10 17:34:54 -0800
commit6ef984af4b0c63c1c33127a12dcfc8e6359f0c9e (patch)
treed17c61ff9f3ae28224fbddac6d26bfc59e2cf755 /src/google/protobuf/wire_format_lite.cc
parentbaca1a8a1aa180c42de6278d3b8286c4496c6a10 (diff)
Down-integrate from internal code base.
Diffstat (limited to 'src/google/protobuf/wire_format_lite.cc')
-rw-r--r--src/google/protobuf/wire_format_lite.cc29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/google/protobuf/wire_format_lite.cc b/src/google/protobuf/wire_format_lite.cc
index 8de82784..c80a7050 100644
--- a/src/google/protobuf/wire_format_lite.cc
+++ b/src/google/protobuf/wire_format_lite.cc
@@ -291,7 +291,7 @@ bool WireFormatLite::ReadPackedEnumNoInline(io::CodedInputStream* input,
int, WireFormatLite::TYPE_ENUM>(input, &value)) {
return false;
}
- if (is_valid(value)) {
+ if (is_valid == NULL || is_valid(value)) {
values->Add(value);
}
}
@@ -451,19 +451,24 @@ void WireFormatLite::WriteMessageMaybeToArray(int field_number,
}
}
-bool WireFormatLite::ReadString(io::CodedInputStream* input,
- string* value) {
- // String is for UTF-8 text only
+static inline bool ReadBytesToString(io::CodedInputStream* input,
+ string* value) GOOGLE_ATTRIBUTE_ALWAYS_INLINE;
+static inline bool ReadBytesToString(io::CodedInputStream* input,
+ string* value) {
uint32 length;
- if (!input->ReadVarint32(&length)) return false;
- if (!input->InternalReadStringInline(value, length)) return false;
- return true;
+ return input->ReadVarint32(&length) &&
+ input->InternalReadStringInline(value, length);
}
-bool WireFormatLite::ReadBytes(io::CodedInputStream* input,
- string* value) {
- uint32 length;
- if (!input->ReadVarint32(&length)) return false;
- return input->InternalReadStringInline(value, length);
+
+bool WireFormatLite::ReadBytes(io::CodedInputStream* input, string* value) {
+ return ReadBytesToString(input, value);
+}
+
+bool WireFormatLite::ReadBytes(io::CodedInputStream* input, string** p) {
+ if (*p == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
+ *p = new ::std::string();
+ }
+ return ReadBytesToString(input, *p);
}
} // namespace internal