| Index: third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
|
| diff --git a/third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc b/third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
|
| index 686e63f2528a3509d601cebdcece3aa4d144d431..e6ca88c21b135e06304c2c42b2f0e649c5e8db83 100644
|
| --- a/third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
|
| +++ b/third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
|
| @@ -69,7 +69,7 @@ ArrayInputStream::~ArrayInputStream() {
|
|
|
| bool ArrayInputStream::Next(const void** data, int* size) {
|
| if (position_ < size_) {
|
| - last_returned_size_ = min(block_size_, size_ - position_);
|
| + last_returned_size_ = std::min(block_size_, size_ - position_);
|
| *data = data_ + position_;
|
| *size = last_returned_size_;
|
| position_ += last_returned_size_;
|
| @@ -122,7 +122,7 @@ ArrayOutputStream::~ArrayOutputStream() {
|
|
|
| bool ArrayOutputStream::Next(void** data, int* size) {
|
| if (position_ < size_) {
|
| - last_returned_size_ = min(block_size_, size_ - position_);
|
| + last_returned_size_ = std::min(block_size_, size_ - position_);
|
| *data = data_ + position_;
|
| *size = last_returned_size_;
|
| position_ += last_returned_size_;
|
| @@ -157,6 +157,7 @@ StringOutputStream::~StringOutputStream() {
|
| }
|
|
|
| bool StringOutputStream::Next(void** data, int* size) {
|
| + GOOGLE_CHECK(target_ != NULL);
|
| int old_size = target_->size();
|
|
|
| // Grow the string.
|
| @@ -176,9 +177,9 @@ bool StringOutputStream::Next(void** data, int* size) {
|
| // Double the size, also make sure that the new size is at least
|
| // kMinimumSize.
|
| STLStringResizeUninitialized(
|
| - target_,
|
| - max(old_size * 2,
|
| - kMinimumSize + 0)); // "+ 0" works around GCC4 weirdness.
|
| + target_,
|
| + std::max(old_size * 2,
|
| + kMinimumSize + 0)); // "+ 0" works around GCC4 weirdness.
|
| }
|
|
|
| *data = mutable_string_data(target_) + old_size;
|
| @@ -188,14 +189,44 @@ bool StringOutputStream::Next(void** data, int* size) {
|
|
|
| void StringOutputStream::BackUp(int count) {
|
| GOOGLE_CHECK_GE(count, 0);
|
| + GOOGLE_CHECK(target_ != NULL);
|
| GOOGLE_CHECK_LE(count, target_->size());
|
| target_->resize(target_->size() - count);
|
| }
|
|
|
| int64 StringOutputStream::ByteCount() const {
|
| + GOOGLE_CHECK(target_ != NULL);
|
| return target_->size();
|
| }
|
|
|
| +void StringOutputStream::SetString(string* target) {
|
| + target_ = target;
|
| +}
|
| +
|
| +// ===================================================================
|
| +
|
| +LazyStringOutputStream::LazyStringOutputStream(
|
| + ResultCallback<string*>* callback)
|
| + : StringOutputStream(NULL),
|
| + callback_(GOOGLE_CHECK_NOTNULL(callback)),
|
| + string_is_set_(false) {
|
| +}
|
| +
|
| +LazyStringOutputStream::~LazyStringOutputStream() {
|
| +}
|
| +
|
| +bool LazyStringOutputStream::Next(void** data, int* size) {
|
| + if (!string_is_set_) {
|
| + SetString(callback_->Run());
|
| + string_is_set_ = true;
|
| + }
|
| + return StringOutputStream::Next(data, size);
|
| +}
|
| +
|
| +int64 LazyStringOutputStream::ByteCount() const {
|
| + return string_is_set_ ? StringOutputStream::ByteCount() : 0;
|
| +}
|
| +
|
| // ===================================================================
|
|
|
| CopyingInputStream::~CopyingInputStream() {}
|
| @@ -204,8 +235,8 @@ int CopyingInputStream::Skip(int count) {
|
| char junk[4096];
|
| int skipped = 0;
|
| while (skipped < count) {
|
| - int bytes = Read(junk, min(count - skipped,
|
| - implicit_cast<int>(sizeof(junk))));
|
| + int bytes =
|
| + Read(junk, std::min(count - skipped, implicit_cast<int>(sizeof(junk))));
|
| if (bytes <= 0) {
|
| // EOF or read error.
|
| return skipped;
|
|
|