aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/io/coded_stream.cc
diff options
context:
space:
mode:
authorFeng Xiao <xfxyjwf@gmail.com>2016-01-06 18:06:43 -0800
committerFeng Xiao <xfxyjwf@gmail.com>2016-01-06 18:10:24 -0800
commit76195058e25d19fc918996d55d3ad69ee55cb77e (patch)
tree3b93b3195a1a411e11b93644429cc6c96668b128 /src/google/protobuf/io/coded_stream.cc
parent363316a8d79ad3bebf47c6347a038b6130212e28 (diff)
downloadprotobuf-76195058e25d19fc918996d55d3ad69ee55cb77e.tar.gz
protobuf-76195058e25d19fc918996d55d3ad69ee55cb77e.tar.bz2
protobuf-76195058e25d19fc918996d55d3ad69ee55cb77e.zip
Patch internal change 111557819.
Defer calls to mutable_unknown_fields() until it is actually required to save memory for C++ lite runtime. Change-Id: Ica9c1fd276cdb164942d1e7b6e098c83ee3ffdc5
Diffstat (limited to 'src/google/protobuf/io/coded_stream.cc')
-rw-r--r--src/google/protobuf/io/coded_stream.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/google/protobuf/io/coded_stream.cc b/src/google/protobuf/io/coded_stream.cc
index 4bcd354f..e3a34d0a 100644
--- a/src/google/protobuf/io/coded_stream.cc
+++ b/src/google/protobuf/io/coded_stream.cc
@@ -629,6 +629,24 @@ CodedOutputStream::CodedOutputStream(ZeroCopyOutputStream* output)
had_error_ = false;
}
+CodedOutputStream::CodedOutputStream(ZeroCopyOutputStream* output,
+ bool do_eager_refresh)
+ : output_(output),
+ buffer_(NULL),
+ buffer_size_(0),
+ total_bytes_(0),
+ had_error_(false),
+ aliasing_enabled_(false) {
+ if (do_eager_refresh) {
+ // Eagerly Refresh() so buffer space is immediately available.
+ Refresh();
+ // The Refresh() may have failed. If the client doesn't write any data,
+ // though, don't consider this an error. If the client does write data, then
+ // another Refresh() will be attempted and it will set the error once again.
+ had_error_ = false;
+ }
+}
+
CodedOutputStream::~CodedOutputStream() {
Trim();
}