Index: third_party/protobuf/src/google/protobuf/arenastring.h |
diff --git a/third_party/protobuf/src/google/protobuf/arenastring.h b/third_party/protobuf/src/google/protobuf/arenastring.h |
index 6c6f80ec786f4e86f1376c252682a823ac5ae203..d983cf6ce50f3ffe85a16d98f56575344900535b 100755 |
--- a/third_party/protobuf/src/google/protobuf/arenastring.h |
+++ b/third_party/protobuf/src/google/protobuf/arenastring.h |
@@ -37,6 +37,7 @@ |
#include <google/protobuf/stubs/common.h> |
#include <google/protobuf/stubs/fastmem.h> |
#include <google/protobuf/arena.h> |
+#include <google/protobuf/generated_message_util.h> |
@@ -63,7 +64,9 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { |
} |
// Basic accessors. |
- inline const ::std::string& Get() const { return *ptr_; } |
+ inline const ::std::string& Get(const ::std::string* /* default_value */) const { |
+ return *ptr_; |
+ } |
inline ::std::string* Mutable(const ::std::string* default_value, |
::google::protobuf::Arena* arena) { |
@@ -147,12 +150,13 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { |
std::swap(ptr_, other->ptr_); |
} |
- // Frees storage (if not on an arena). |
+ // Frees storage (if not on an arena) and sets field to default value. |
inline void Destroy(const ::std::string* default_value, |
::google::protobuf::Arena* arena) { |
if (arena == NULL && ptr_ != default_value) { |
delete ptr_; |
} |
+ ptr_ = const_cast< ::std::string* >(default_value); |
} |
// Clears content, but keeps allocated string if arena != NULL, to avoid the |
@@ -210,19 +214,11 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { |
} |
} |
-#if LANG_CXX11 |
- void SetNoArena(const ::std::string* default_value, ::std::string&& value) { |
- if (IsDefault(default_value)) { |
- ptr_ = new ::std::string(std::move(value)); |
- } else { |
- *ptr_ = std::move(value); |
- } |
- } |
-#endif |
- |
void AssignWithDefault(const ::std::string* default_value, ArenaStringPtr value); |
- inline const ::std::string& GetNoArena() const { return *ptr_; } |
+ inline const ::std::string& GetNoArena(const ::std::string* /* default_value */) const { |
+ return *ptr_; |
+ } |
::std::string* MutableNoArena(const ::std::string* default_value); |
@@ -275,24 +271,27 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { |
return &ptr_; |
} |
- inline bool IsDefault(const ::std::string* default_value) const { |
- return ptr_ == default_value; |
- } |
- |
private: |
::std::string* ptr_; |
GOOGLE_ATTRIBUTE_NOINLINE void CreateInstance(::google::protobuf::Arena* arena, |
const ::std::string* initial_value) { |
- GOOGLE_DCHECK(initial_value != NULL); |
- ptr_ = new ::std::string(*initial_value); |
+ // Assumes ptr_ is not NULL. |
+ if (initial_value != NULL) { |
+ ptr_ = new ::std::string(*initial_value); |
+ } else { |
+ ptr_ = new ::std::string(); |
+ } |
if (arena != NULL) { |
arena->Own(ptr_); |
} |
} |
GOOGLE_ATTRIBUTE_NOINLINE void CreateInstanceNoArena(const ::std::string* initial_value) { |
- GOOGLE_DCHECK(initial_value != NULL); |
- ptr_ = new ::std::string(*initial_value); |
+ if (initial_value != NULL) { |
+ ptr_ = new ::std::string(*initial_value); |
+ } else { |
+ ptr_ = new ::std::string(); |
+ } |
} |
}; |