Replace kEmptyString wth OnceInit initialized string*

pull/1/head
xiaofeng@google.com 11 years ago
parent f0b6a5cfeb
commit 37c7426b47
  1. 2
      src/google/protobuf/compiler/cpp/cpp_string_field.cc
  2. 30
      src/google/protobuf/compiler/plugin.pb.cc
  3. 90
      src/google/protobuf/compiler/plugin.pb.h
  4. 8
      src/google/protobuf/descriptor.cc
  5. 138
      src/google/protobuf/descriptor.pb.cc
  6. 414
      src/google/protobuf/descriptor.pb.h
  7. 10
      src/google/protobuf/generated_message_reflection.cc
  8. 7
      src/google/protobuf/generated_message_util.cc
  9. 14
      src/google/protobuf/generated_message_util.h
  10. 2
      src/google/protobuf/repeated_field.h

@ -53,7 +53,7 @@ void SetStringVariables(const FieldDescriptor* descriptor,
(*variables)["default_length"] = (*variables)["default_length"] =
SimpleItoa(descriptor->default_value_string().length()); SimpleItoa(descriptor->default_value_string().length());
(*variables)["default_variable"] = descriptor->default_value_string().empty() (*variables)["default_variable"] = descriptor->default_value_string().empty()
? "&::google::protobuf::internal::kEmptyString" ? "&::google::protobuf::internal::GetEmptyString()"
: "_default_" + FieldName(descriptor) + "_"; : "_default_" + FieldName(descriptor) + "_";
(*variables)["pointer_type"] = (*variables)["pointer_type"] =
descriptor->type() == FieldDescriptor::TYPE_BYTES ? "void" : "char"; descriptor->type() == FieldDescriptor::TYPE_BYTES ? "void" : "char";

@ -184,7 +184,7 @@ CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from)
void CodeGeneratorRequest::SharedCtor() { void CodeGeneratorRequest::SharedCtor() {
_cached_size_ = 0; _cached_size_ = 0;
parameter_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); parameter_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
::memset(_has_bits_, 0, sizeof(_has_bits_)); ::memset(_has_bits_, 0, sizeof(_has_bits_));
} }
@ -193,7 +193,7 @@ CodeGeneratorRequest::~CodeGeneratorRequest() {
} }
void CodeGeneratorRequest::SharedDtor() { void CodeGeneratorRequest::SharedDtor() {
if (parameter_ != &::google::protobuf::internal::kEmptyString) { if (parameter_ != &::google::protobuf::internal::GetEmptyString()) {
delete parameter_; delete parameter_;
} }
if (this != default_instance_) { if (this != default_instance_) {
@ -224,7 +224,7 @@ CodeGeneratorRequest* CodeGeneratorRequest::New() const {
void CodeGeneratorRequest::Clear() { void CodeGeneratorRequest::Clear() {
if (_has_bits_[1 / 32] & (0xffu << (1 % 32))) { if (_has_bits_[1 / 32] & (0xffu << (1 % 32))) {
if (has_parameter()) { if (has_parameter()) {
if (parameter_ != &::google::protobuf::internal::kEmptyString) { if (parameter_ != &::google::protobuf::internal::GetEmptyString()) {
parameter_->clear(); parameter_->clear();
} }
} }
@ -501,9 +501,9 @@ CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorRespon
void CodeGeneratorResponse_File::SharedCtor() { void CodeGeneratorResponse_File::SharedCtor() {
_cached_size_ = 0; _cached_size_ = 0;
name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
insertion_point_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); insertion_point_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
content_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); content_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
::memset(_has_bits_, 0, sizeof(_has_bits_)); ::memset(_has_bits_, 0, sizeof(_has_bits_));
} }
@ -512,13 +512,13 @@ CodeGeneratorResponse_File::~CodeGeneratorResponse_File() {
} }
void CodeGeneratorResponse_File::SharedDtor() { void CodeGeneratorResponse_File::SharedDtor() {
if (name_ != &::google::protobuf::internal::kEmptyString) { if (name_ != &::google::protobuf::internal::GetEmptyString()) {
delete name_; delete name_;
} }
if (insertion_point_ != &::google::protobuf::internal::kEmptyString) { if (insertion_point_ != &::google::protobuf::internal::GetEmptyString()) {
delete insertion_point_; delete insertion_point_;
} }
if (content_ != &::google::protobuf::internal::kEmptyString) { if (content_ != &::google::protobuf::internal::GetEmptyString()) {
delete content_; delete content_;
} }
if (this != default_instance_) { if (this != default_instance_) {
@ -549,17 +549,17 @@ CodeGeneratorResponse_File* CodeGeneratorResponse_File::New() const {
void CodeGeneratorResponse_File::Clear() { void CodeGeneratorResponse_File::Clear() {
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (has_name()) { if (has_name()) {
if (name_ != &::google::protobuf::internal::kEmptyString) { if (name_ != &::google::protobuf::internal::GetEmptyString()) {
name_->clear(); name_->clear();
} }
} }
if (has_insertion_point()) { if (has_insertion_point()) {
if (insertion_point_ != &::google::protobuf::internal::kEmptyString) { if (insertion_point_ != &::google::protobuf::internal::GetEmptyString()) {
insertion_point_->clear(); insertion_point_->clear();
} }
} }
if (has_content()) { if (has_content()) {
if (content_ != &::google::protobuf::internal::kEmptyString) { if (content_ != &::google::protobuf::internal::GetEmptyString()) {
content_->clear(); content_->clear();
} }
} }
@ -839,7 +839,7 @@ CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from)
void CodeGeneratorResponse::SharedCtor() { void CodeGeneratorResponse::SharedCtor() {
_cached_size_ = 0; _cached_size_ = 0;
error_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); error_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
::memset(_has_bits_, 0, sizeof(_has_bits_)); ::memset(_has_bits_, 0, sizeof(_has_bits_));
} }
@ -848,7 +848,7 @@ CodeGeneratorResponse::~CodeGeneratorResponse() {
} }
void CodeGeneratorResponse::SharedDtor() { void CodeGeneratorResponse::SharedDtor() {
if (error_ != &::google::protobuf::internal::kEmptyString) { if (error_ != &::google::protobuf::internal::GetEmptyString()) {
delete error_; delete error_;
} }
if (this != default_instance_) { if (this != default_instance_) {
@ -879,7 +879,7 @@ CodeGeneratorResponse* CodeGeneratorResponse::New() const {
void CodeGeneratorResponse::Clear() { void CodeGeneratorResponse::Clear() {
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (has_error()) { if (has_error()) {
if (error_ != &::google::protobuf::internal::kEmptyString) { if (error_ != &::google::protobuf::internal::GetEmptyString()) {
error_->clear(); error_->clear();
} }
} }

@ -438,7 +438,7 @@ inline void CodeGeneratorRequest::clear_has_parameter() {
_has_bits_[0] &= ~0x00000002u; _has_bits_[0] &= ~0x00000002u;
} }
inline void CodeGeneratorRequest::clear_parameter() { inline void CodeGeneratorRequest::clear_parameter() {
if (parameter_ != &::google::protobuf::internal::kEmptyString) { if (parameter_ != &::google::protobuf::internal::GetEmptyString()) {
parameter_->clear(); parameter_->clear();
} }
clear_has_parameter(); clear_has_parameter();
@ -448,44 +448,44 @@ inline const ::std::string& CodeGeneratorRequest::parameter() const {
} }
inline void CodeGeneratorRequest::set_parameter(const ::std::string& value) { inline void CodeGeneratorRequest::set_parameter(const ::std::string& value) {
set_has_parameter(); set_has_parameter();
if (parameter_ == &::google::protobuf::internal::kEmptyString) { if (parameter_ == &::google::protobuf::internal::GetEmptyString()) {
parameter_ = new ::std::string; parameter_ = new ::std::string;
} }
parameter_->assign(value); parameter_->assign(value);
} }
inline void CodeGeneratorRequest::set_parameter(const char* value) { inline void CodeGeneratorRequest::set_parameter(const char* value) {
set_has_parameter(); set_has_parameter();
if (parameter_ == &::google::protobuf::internal::kEmptyString) { if (parameter_ == &::google::protobuf::internal::GetEmptyString()) {
parameter_ = new ::std::string; parameter_ = new ::std::string;
} }
parameter_->assign(value); parameter_->assign(value);
} }
inline void CodeGeneratorRequest::set_parameter(const char* value, size_t size) { inline void CodeGeneratorRequest::set_parameter(const char* value, size_t size) {
set_has_parameter(); set_has_parameter();
if (parameter_ == &::google::protobuf::internal::kEmptyString) { if (parameter_ == &::google::protobuf::internal::GetEmptyString()) {
parameter_ = new ::std::string; parameter_ = new ::std::string;
} }
parameter_->assign(reinterpret_cast<const char*>(value), size); parameter_->assign(reinterpret_cast<const char*>(value), size);
} }
inline ::std::string* CodeGeneratorRequest::mutable_parameter() { inline ::std::string* CodeGeneratorRequest::mutable_parameter() {
set_has_parameter(); set_has_parameter();
if (parameter_ == &::google::protobuf::internal::kEmptyString) { if (parameter_ == &::google::protobuf::internal::GetEmptyString()) {
parameter_ = new ::std::string; parameter_ = new ::std::string;
} }
return parameter_; return parameter_;
} }
inline ::std::string* CodeGeneratorRequest::release_parameter() { inline ::std::string* CodeGeneratorRequest::release_parameter() {
clear_has_parameter(); clear_has_parameter();
if (parameter_ == &::google::protobuf::internal::kEmptyString) { if (parameter_ == &::google::protobuf::internal::GetEmptyString()) {
return NULL; return NULL;
} else { } else {
::std::string* temp = parameter_; ::std::string* temp = parameter_;
parameter_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); parameter_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
return temp; return temp;
} }
} }
inline void CodeGeneratorRequest::set_allocated_parameter(::std::string* parameter) { inline void CodeGeneratorRequest::set_allocated_parameter(::std::string* parameter) {
if (parameter_ != &::google::protobuf::internal::kEmptyString) { if (parameter_ != &::google::protobuf::internal::GetEmptyString()) {
delete parameter_; delete parameter_;
} }
if (parameter) { if (parameter) {
@ -493,7 +493,7 @@ inline void CodeGeneratorRequest::set_allocated_parameter(::std::string* paramet
parameter_ = parameter; parameter_ = parameter;
} else { } else {
clear_has_parameter(); clear_has_parameter();
parameter_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); parameter_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
} }
} }
@ -537,7 +537,7 @@ inline void CodeGeneratorResponse_File::clear_has_name() {
_has_bits_[0] &= ~0x00000001u; _has_bits_[0] &= ~0x00000001u;
} }
inline void CodeGeneratorResponse_File::clear_name() { inline void CodeGeneratorResponse_File::clear_name() {
if (name_ != &::google::protobuf::internal::kEmptyString) { if (name_ != &::google::protobuf::internal::GetEmptyString()) {
name_->clear(); name_->clear();
} }
clear_has_name(); clear_has_name();
@ -547,44 +547,44 @@ inline const ::std::string& CodeGeneratorResponse_File::name() const {
} }
inline void CodeGeneratorResponse_File::set_name(const ::std::string& value) { inline void CodeGeneratorResponse_File::set_name(const ::std::string& value) {
set_has_name(); set_has_name();
if (name_ == &::google::protobuf::internal::kEmptyString) { if (name_ == &::google::protobuf::internal::GetEmptyString()) {
name_ = new ::std::string; name_ = new ::std::string;
} }
name_->assign(value); name_->assign(value);
} }
inline void CodeGeneratorResponse_File::set_name(const char* value) { inline void CodeGeneratorResponse_File::set_name(const char* value) {
set_has_name(); set_has_name();
if (name_ == &::google::protobuf::internal::kEmptyString) { if (name_ == &::google::protobuf::internal::GetEmptyString()) {
name_ = new ::std::string; name_ = new ::std::string;
} }
name_->assign(value); name_->assign(value);
} }
inline void CodeGeneratorResponse_File::set_name(const char* value, size_t size) { inline void CodeGeneratorResponse_File::set_name(const char* value, size_t size) {
set_has_name(); set_has_name();
if (name_ == &::google::protobuf::internal::kEmptyString) { if (name_ == &::google::protobuf::internal::GetEmptyString()) {
name_ = new ::std::string; name_ = new ::std::string;
} }
name_->assign(reinterpret_cast<const char*>(value), size); name_->assign(reinterpret_cast<const char*>(value), size);
} }
inline ::std::string* CodeGeneratorResponse_File::mutable_name() { inline ::std::string* CodeGeneratorResponse_File::mutable_name() {
set_has_name(); set_has_name();
if (name_ == &::google::protobuf::internal::kEmptyString) { if (name_ == &::google::protobuf::internal::GetEmptyString()) {
name_ = new ::std::string; name_ = new ::std::string;
} }
return name_; return name_;
} }
inline ::std::string* CodeGeneratorResponse_File::release_name() { inline ::std::string* CodeGeneratorResponse_File::release_name() {
clear_has_name(); clear_has_name();
if (name_ == &::google::protobuf::internal::kEmptyString) { if (name_ == &::google::protobuf::internal::GetEmptyString()) {
return NULL; return NULL;
} else { } else {
::std::string* temp = name_; ::std::string* temp = name_;
name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
return temp; return temp;
} }
} }
inline void CodeGeneratorResponse_File::set_allocated_name(::std::string* name) { inline void CodeGeneratorResponse_File::set_allocated_name(::std::string* name) {
if (name_ != &::google::protobuf::internal::kEmptyString) { if (name_ != &::google::protobuf::internal::GetEmptyString()) {
delete name_; delete name_;
} }
if (name) { if (name) {
@ -592,7 +592,7 @@ inline void CodeGeneratorResponse_File::set_allocated_name(::std::string* name)
name_ = name; name_ = name;
} else { } else {
clear_has_name(); clear_has_name();
name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
} }
} }
@ -607,7 +607,7 @@ inline void CodeGeneratorResponse_File::clear_has_insertion_point() {
_has_bits_[0] &= ~0x00000002u; _has_bits_[0] &= ~0x00000002u;
} }
inline void CodeGeneratorResponse_File::clear_insertion_point() { inline void CodeGeneratorResponse_File::clear_insertion_point() {
if (insertion_point_ != &::google::protobuf::internal::kEmptyString) { if (insertion_point_ != &::google::protobuf::internal::GetEmptyString()) {
insertion_point_->clear(); insertion_point_->clear();
} }
clear_has_insertion_point(); clear_has_insertion_point();
@ -617,44 +617,44 @@ inline const ::std::string& CodeGeneratorResponse_File::insertion_point() const
} }
inline void CodeGeneratorResponse_File::set_insertion_point(const ::std::string& value) { inline void CodeGeneratorResponse_File::set_insertion_point(const ::std::string& value) {
set_has_insertion_point(); set_has_insertion_point();
if (insertion_point_ == &::google::protobuf::internal::kEmptyString) { if (insertion_point_ == &::google::protobuf::internal::GetEmptyString()) {
insertion_point_ = new ::std::string; insertion_point_ = new ::std::string;
} }
insertion_point_->assign(value); insertion_point_->assign(value);
} }
inline void CodeGeneratorResponse_File::set_insertion_point(const char* value) { inline void CodeGeneratorResponse_File::set_insertion_point(const char* value) {
set_has_insertion_point(); set_has_insertion_point();
if (insertion_point_ == &::google::protobuf::internal::kEmptyString) { if (insertion_point_ == &::google::protobuf::internal::GetEmptyString()) {
insertion_point_ = new ::std::string; insertion_point_ = new ::std::string;
} }
insertion_point_->assign(value); insertion_point_->assign(value);
} }
inline void CodeGeneratorResponse_File::set_insertion_point(const char* value, size_t size) { inline void CodeGeneratorResponse_File::set_insertion_point(const char* value, size_t size) {
set_has_insertion_point(); set_has_insertion_point();
if (insertion_point_ == &::google::protobuf::internal::kEmptyString) { if (insertion_point_ == &::google::protobuf::internal::GetEmptyString()) {
insertion_point_ = new ::std::string; insertion_point_ = new ::std::string;
} }
insertion_point_->assign(reinterpret_cast<const char*>(value), size); insertion_point_->assign(reinterpret_cast<const char*>(value), size);
} }
inline ::std::string* CodeGeneratorResponse_File::mutable_insertion_point() { inline ::std::string* CodeGeneratorResponse_File::mutable_insertion_point() {
set_has_insertion_point(); set_has_insertion_point();
if (insertion_point_ == &::google::protobuf::internal::kEmptyString) { if (insertion_point_ == &::google::protobuf::internal::GetEmptyString()) {
insertion_point_ = new ::std::string; insertion_point_ = new ::std::string;
} }
return insertion_point_; return insertion_point_;
} }
inline ::std::string* CodeGeneratorResponse_File::release_insertion_point() { inline ::std::string* CodeGeneratorResponse_File::release_insertion_point() {
clear_has_insertion_point(); clear_has_insertion_point();
if (insertion_point_ == &::google::protobuf::internal::kEmptyString) { if (insertion_point_ == &::google::protobuf::internal::GetEmptyString()) {
return NULL; return NULL;
} else { } else {
::std::string* temp = insertion_point_; ::std::string* temp = insertion_point_;
insertion_point_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); insertion_point_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
return temp; return temp;
} }
} }
inline void CodeGeneratorResponse_File::set_allocated_insertion_point(::std::string* insertion_point) { inline void CodeGeneratorResponse_File::set_allocated_insertion_point(::std::string* insertion_point) {
if (insertion_point_ != &::google::protobuf::internal::kEmptyString) { if (insertion_point_ != &::google::protobuf::internal::GetEmptyString()) {
delete insertion_point_; delete insertion_point_;
} }
if (insertion_point) { if (insertion_point) {
@ -662,7 +662,7 @@ inline void CodeGeneratorResponse_File::set_allocated_insertion_point(::std::str
insertion_point_ = insertion_point; insertion_point_ = insertion_point;
} else { } else {
clear_has_insertion_point(); clear_has_insertion_point();
insertion_point_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); insertion_point_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
} }
} }
@ -677,7 +677,7 @@ inline void CodeGeneratorResponse_File::clear_has_content() {
_has_bits_[0] &= ~0x00000004u; _has_bits_[0] &= ~0x00000004u;
} }
inline void CodeGeneratorResponse_File::clear_content() { inline void CodeGeneratorResponse_File::clear_content() {
if (content_ != &::google::protobuf::internal::kEmptyString) { if (content_ != &::google::protobuf::internal::GetEmptyString()) {
content_->clear(); content_->clear();
} }
clear_has_content(); clear_has_content();
@ -687,44 +687,44 @@ inline const ::std::string& CodeGeneratorResponse_File::content() const {
} }
inline void CodeGeneratorResponse_File::set_content(const ::std::string& value) { inline void CodeGeneratorResponse_File::set_content(const ::std::string& value) {
set_has_content(); set_has_content();
if (content_ == &::google::protobuf::internal::kEmptyString) { if (content_ == &::google::protobuf::internal::GetEmptyString()) {
content_ = new ::std::string; content_ = new ::std::string;
} }
content_->assign(value); content_->assign(value);
} }
inline void CodeGeneratorResponse_File::set_content(const char* value) { inline void CodeGeneratorResponse_File::set_content(const char* value) {
set_has_content(); set_has_content();
if (content_ == &::google::protobuf::internal::kEmptyString) { if (content_ == &::google::protobuf::internal::GetEmptyString()) {
content_ = new ::std::string; content_ = new ::std::string;
} }
content_->assign(value); content_->assign(value);
} }
inline void CodeGeneratorResponse_File::set_content(const char* value, size_t size) { inline void CodeGeneratorResponse_File::set_content(const char* value, size_t size) {
set_has_content(); set_has_content();
if (content_ == &::google::protobuf::internal::kEmptyString) { if (content_ == &::google::protobuf::internal::GetEmptyString()) {
content_ = new ::std::string; content_ = new ::std::string;
} }
content_->assign(reinterpret_cast<const char*>(value), size); content_->assign(reinterpret_cast<const char*>(value), size);
} }
inline ::std::string* CodeGeneratorResponse_File::mutable_content() { inline ::std::string* CodeGeneratorResponse_File::mutable_content() {
set_has_content(); set_has_content();
if (content_ == &::google::protobuf::internal::kEmptyString) { if (content_ == &::google::protobuf::internal::GetEmptyString()) {
content_ = new ::std::string; content_ = new ::std::string;
} }
return content_; return content_;
} }
inline ::std::string* CodeGeneratorResponse_File::release_content() { inline ::std::string* CodeGeneratorResponse_File::release_content() {
clear_has_content(); clear_has_content();
if (content_ == &::google::protobuf::internal::kEmptyString) { if (content_ == &::google::protobuf::internal::GetEmptyString()) {
return NULL; return NULL;
} else { } else {
::std::string* temp = content_; ::std::string* temp = content_;
content_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); content_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
return temp; return temp;
} }
} }
inline void CodeGeneratorResponse_File::set_allocated_content(::std::string* content) { inline void CodeGeneratorResponse_File::set_allocated_content(::std::string* content) {
if (content_ != &::google::protobuf::internal::kEmptyString) { if (content_ != &::google::protobuf::internal::GetEmptyString()) {
delete content_; delete content_;
} }
if (content) { if (content) {
@ -732,7 +732,7 @@ inline void CodeGeneratorResponse_File::set_allocated_content(::std::string* con
content_ = content; content_ = content;
} else { } else {
clear_has_content(); clear_has_content();
content_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); content_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
} }
} }
@ -751,7 +751,7 @@ inline void CodeGeneratorResponse::clear_has_error() {
_has_bits_[0] &= ~0x00000001u; _has_bits_[0] &= ~0x00000001u;
} }
inline void CodeGeneratorResponse::clear_error() { inline void CodeGeneratorResponse::clear_error() {
if (error_ != &::google::protobuf::internal::kEmptyString) { if (error_ != &::google::protobuf::internal::GetEmptyString()) {
error_->clear(); error_->clear();
} }
clear_has_error(); clear_has_error();
@ -761,44 +761,44 @@ inline const ::std::string& CodeGeneratorResponse::error() const {
} }
inline void CodeGeneratorResponse::set_error(const ::std::string& value) { inline void CodeGeneratorResponse::set_error(const ::std::string& value) {
set_has_error(); set_has_error();
if (error_ == &::google::protobuf::internal::kEmptyString) { if (error_ == &::google::protobuf::internal::GetEmptyString()) {
error_ = new ::std::string; error_ = new ::std::string;
} }
error_->assign(value); error_->assign(value);
} }
inline void CodeGeneratorResponse::set_error(const char* value) { inline void CodeGeneratorResponse::set_error(const char* value) {
set_has_error(); set_has_error();
if (error_ == &::google::protobuf::internal::kEmptyString) { if (error_ == &::google::protobuf::internal::GetEmptyString()) {
error_ = new ::std::string; error_ = new ::std::string;
} }
error_->assign(value); error_->assign(value);
} }
inline void CodeGeneratorResponse::set_error(const char* value, size_t size) { inline void CodeGeneratorResponse::set_error(const char* value, size_t size) {
set_has_error(); set_has_error();
if (error_ == &::google::protobuf::internal::kEmptyString) { if (error_ == &::google::protobuf::internal::GetEmptyString()) {
error_ = new ::std::string; error_ = new ::std::string;
} }
error_->assign(reinterpret_cast<const char*>(value), size); error_->assign(reinterpret_cast<const char*>(value), size);
} }
inline ::std::string* CodeGeneratorResponse::mutable_error() { inline ::std::string* CodeGeneratorResponse::mutable_error() {
set_has_error(); set_has_error();
if (error_ == &::google::protobuf::internal::kEmptyString) { if (error_ == &::google::protobuf::internal::GetEmptyString()) {
error_ = new ::std::string; error_ = new ::std::string;
} }
return error_; return error_;
} }
inline ::std::string* CodeGeneratorResponse::release_error() { inline ::std::string* CodeGeneratorResponse::release_error() {
clear_has_error(); clear_has_error();
if (error_ == &::google::protobuf::internal::kEmptyString) { if (error_ == &::google::protobuf::internal::GetEmptyString()) {
return NULL; return NULL;
} else { } else {
::std::string* temp = error_; ::std::string* temp = error_;
error_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); error_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
return temp; return temp;
} }
} }
inline void CodeGeneratorResponse::set_allocated_error(::std::string* error) { inline void CodeGeneratorResponse::set_allocated_error(::std::string* error) {
if (error_ != &::google::protobuf::internal::kEmptyString) { if (error_ != &::google::protobuf::internal::GetEmptyString()) {
delete error_; delete error_;
} }
if (error) { if (error) {
@ -806,7 +806,7 @@ inline void CodeGeneratorResponse::set_allocated_error(::std::string* error) {
error_ = error; error_ = error;
} else { } else {
clear_has_error(); clear_has_error();
error_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); error_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
} }
} }

@ -139,8 +139,6 @@ const int FieldDescriptor::kLastReservedNumber;
namespace { namespace {
const string kEmptyString;
string ToCamelCase(const string& input) { string ToCamelCase(const string& input) {
bool capitalize_next = false; bool capitalize_next = false;
string result; string result;
@ -2757,7 +2755,7 @@ Symbol DescriptorBuilder::NewPlaceholder(const string& name,
placeholder_name = tables_->AllocateString( placeholder_name = tables_->AllocateString(
placeholder_full_name->substr(dotpos + 1)); placeholder_full_name->substr(dotpos + 1));
} else { } else {
placeholder_package = &kEmptyString; placeholder_package = &::google::protobuf::internal::GetEmptyString();
placeholder_name = placeholder_full_name; placeholder_name = placeholder_full_name;
} }
@ -2843,7 +2841,7 @@ const FileDescriptor* DescriptorBuilder::NewPlaceholderFile(
memset(placeholder, 0, sizeof(*placeholder)); memset(placeholder, 0, sizeof(*placeholder));
placeholder->name_ = tables_->AllocateString(name); placeholder->name_ = tables_->AllocateString(name);
placeholder->package_ = &kEmptyString; placeholder->package_ = &::google::protobuf::internal::GetEmptyString();
placeholder->pool_ = pool_; placeholder->pool_ = pool_;
placeholder->options_ = &FileOptions::default_instance(); placeholder->options_ = &FileOptions::default_instance();
placeholder->tables_ = &FileDescriptorTables::kEmpty; placeholder->tables_ = &FileDescriptorTables::kEmpty;
@ -3485,7 +3483,7 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto,
result->default_value_enum_ = NULL; result->default_value_enum_ = NULL;
break; break;
case FieldDescriptor::CPPTYPE_STRING: case FieldDescriptor::CPPTYPE_STRING:
result->default_value_string_ = &kEmptyString; result->default_value_string_ = &::google::protobuf::internal::GetEmptyString();
break; break;
case FieldDescriptor::CPPTYPE_MESSAGE: case FieldDescriptor::CPPTYPE_MESSAGE:
break; break;

@ -962,8 +962,8 @@ FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from)
void FileDescriptorProto::SharedCtor() { void FileDescriptorProto::SharedCtor() {
_cached_size_ = 0; _cached_size_ = 0;
name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
package_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); package_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
options_ = NULL; options_ = NULL;
source_code_info_ = NULL; source_code_info_ = NULL;
::memset(_has_bits_, 0, sizeof(_has_bits_)); ::memset(_has_bits_, 0, sizeof(_has_bits_));
@ -974,10 +974,10 @@ FileDescriptorProto::~FileDescriptorProto() {
} }
void FileDescriptorProto::SharedDtor() { void FileDescriptorProto::SharedDtor() {
if (name_ != &::google::protobuf::internal::kEmptyString) { if (name_ != &::google::protobuf::internal::GetEmptyString()) {
delete name_; delete name_;
} }
if (package_ != &::google::protobuf::internal::kEmptyString) { if (package_ != &::google::protobuf::internal::GetEmptyString()) {
delete package_; delete package_;
} }
if (this != default_instance_) { if (this != default_instance_) {
@ -1010,12 +1010,12 @@ FileDescriptorProto* FileDescriptorProto::New() const {
void FileDescriptorProto::Clear() { void FileDescriptorProto::Clear() {
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (has_name()) { if (has_name()) {
if (name_ != &::google::protobuf::internal::kEmptyString) { if (name_ != &::google::protobuf::internal::GetEmptyString()) {
name_->clear(); name_->clear();
} }
} }
if (has_package()) { if (has_package()) {
if (package_ != &::google::protobuf::internal::kEmptyString) { if (package_ != &::google::protobuf::internal::GetEmptyString()) {
package_->clear(); package_->clear();
} }
} }
@ -1902,7 +1902,7 @@ DescriptorProto::DescriptorProto(const DescriptorProto& from)
void DescriptorProto::SharedCtor() { void DescriptorProto::SharedCtor() {
_cached_size_ = 0; _cached_size_ = 0;
name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
options_ = NULL; options_ = NULL;
::memset(_has_bits_, 0, sizeof(_has_bits_)); ::memset(_has_bits_, 0, sizeof(_has_bits_));
} }
@ -1912,7 +1912,7 @@ DescriptorProto::~DescriptorProto() {
} }
void DescriptorProto::SharedDtor() { void DescriptorProto::SharedDtor() {
if (name_ != &::google::protobuf::internal::kEmptyString) { if (name_ != &::google::protobuf::internal::GetEmptyString()) {
delete name_; delete name_;
} }
if (this != default_instance_) { if (this != default_instance_) {
@ -1944,7 +1944,7 @@ DescriptorProto* DescriptorProto::New() const {
void DescriptorProto::Clear() { void DescriptorProto::Clear() {
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (has_name()) { if (has_name()) {
if (name_ != &::google::protobuf::internal::kEmptyString) { if (name_ != &::google::protobuf::internal::GetEmptyString()) {
name_->clear(); name_->clear();
} }
} }
@ -2464,13 +2464,13 @@ FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from)
void FieldDescriptorProto::SharedCtor() { void FieldDescriptorProto::SharedCtor() {
_cached_size_ = 0; _cached_size_ = 0;
name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
number_ = 0; number_ = 0;
label_ = 1; label_ = 1;
type_ = 1; type_ = 1;
type_name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); type_name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
extendee_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); extendee_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
default_value_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); default_value_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
options_ = NULL; options_ = NULL;
::memset(_has_bits_, 0, sizeof(_has_bits_)); ::memset(_has_bits_, 0, sizeof(_has_bits_));
} }
@ -2480,16 +2480,16 @@ FieldDescriptorProto::~FieldDescriptorProto() {
} }
void FieldDescriptorProto::SharedDtor() { void FieldDescriptorProto::SharedDtor() {
if (name_ != &::google::protobuf::internal::kEmptyString) { if (name_ != &::google::protobuf::internal::GetEmptyString()) {
delete name_; delete name_;
} }
if (type_name_ != &::google::protobuf::internal::kEmptyString) { if (type_name_ != &::google::protobuf::internal::GetEmptyString()) {
delete type_name_; delete type_name_;
} }
if (extendee_ != &::google::protobuf::internal::kEmptyString) { if (extendee_ != &::google::protobuf::internal::GetEmptyString()) {
delete extendee_; delete extendee_;
} }
if (default_value_ != &::google::protobuf::internal::kEmptyString) { if (default_value_ != &::google::protobuf::internal::GetEmptyString()) {
delete default_value_; delete default_value_;
} }
if (this != default_instance_) { if (this != default_instance_) {
@ -2521,7 +2521,7 @@ FieldDescriptorProto* FieldDescriptorProto::New() const {
void FieldDescriptorProto::Clear() { void FieldDescriptorProto::Clear() {
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (has_name()) { if (has_name()) {
if (name_ != &::google::protobuf::internal::kEmptyString) { if (name_ != &::google::protobuf::internal::GetEmptyString()) {
name_->clear(); name_->clear();
} }
} }
@ -2529,17 +2529,17 @@ void FieldDescriptorProto::Clear() {
label_ = 1; label_ = 1;
type_ = 1; type_ = 1;
if (has_type_name()) { if (has_type_name()) {
if (type_name_ != &::google::protobuf::internal::kEmptyString) { if (type_name_ != &::google::protobuf::internal::GetEmptyString()) {
type_name_->clear(); type_name_->clear();
} }
} }
if (has_extendee()) { if (has_extendee()) {
if (extendee_ != &::google::protobuf::internal::kEmptyString) { if (extendee_ != &::google::protobuf::internal::GetEmptyString()) {
extendee_->clear(); extendee_->clear();
} }
} }
if (has_default_value()) { if (has_default_value()) {
if (default_value_ != &::google::protobuf::internal::kEmptyString) { if (default_value_ != &::google::protobuf::internal::GetEmptyString()) {
default_value_->clear(); default_value_->clear();
} }
} }
@ -3035,7 +3035,7 @@ EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from)
void EnumDescriptorProto::SharedCtor() { void EnumDescriptorProto::SharedCtor() {
_cached_size_ = 0; _cached_size_ = 0;
name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
options_ = NULL; options_ = NULL;
::memset(_has_bits_, 0, sizeof(_has_bits_)); ::memset(_has_bits_, 0, sizeof(_has_bits_));
} }
@ -3045,7 +3045,7 @@ EnumDescriptorProto::~EnumDescriptorProto() {
} }
void EnumDescriptorProto::SharedDtor() { void EnumDescriptorProto::SharedDtor() {
if (name_ != &::google::protobuf::internal::kEmptyString) { if (name_ != &::google::protobuf::internal::GetEmptyString()) {
delete name_; delete name_;
} }
if (this != default_instance_) { if (this != default_instance_) {
@ -3077,7 +3077,7 @@ EnumDescriptorProto* EnumDescriptorProto::New() const {
void EnumDescriptorProto::Clear() { void EnumDescriptorProto::Clear() {
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (has_name()) { if (has_name()) {
if (name_ != &::google::protobuf::internal::kEmptyString) { if (name_ != &::google::protobuf::internal::GetEmptyString()) {
name_->clear(); name_->clear();
} }
} }
@ -3351,7 +3351,7 @@ EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProt
void EnumValueDescriptorProto::SharedCtor() { void EnumValueDescriptorProto::SharedCtor() {
_cached_size_ = 0; _cached_size_ = 0;
name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
number_ = 0; number_ = 0;
options_ = NULL; options_ = NULL;
::memset(_has_bits_, 0, sizeof(_has_bits_)); ::memset(_has_bits_, 0, sizeof(_has_bits_));
@ -3362,7 +3362,7 @@ EnumValueDescriptorProto::~EnumValueDescriptorProto() {
} }
void EnumValueDescriptorProto::SharedDtor() { void EnumValueDescriptorProto::SharedDtor() {
if (name_ != &::google::protobuf::internal::kEmptyString) { if (name_ != &::google::protobuf::internal::GetEmptyString()) {
delete name_; delete name_;
} }
if (this != default_instance_) { if (this != default_instance_) {
@ -3394,7 +3394,7 @@ EnumValueDescriptorProto* EnumValueDescriptorProto::New() const {
void EnumValueDescriptorProto::Clear() { void EnumValueDescriptorProto::Clear() {
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (has_name()) { if (has_name()) {
if (name_ != &::google::protobuf::internal::kEmptyString) { if (name_ != &::google::protobuf::internal::GetEmptyString()) {
name_->clear(); name_->clear();
} }
} }
@ -3664,7 +3664,7 @@ ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& fro
void ServiceDescriptorProto::SharedCtor() { void ServiceDescriptorProto::SharedCtor() {
_cached_size_ = 0; _cached_size_ = 0;
name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
options_ = NULL; options_ = NULL;
::memset(_has_bits_, 0, sizeof(_has_bits_)); ::memset(_has_bits_, 0, sizeof(_has_bits_));
} }
@ -3674,7 +3674,7 @@ ServiceDescriptorProto::~ServiceDescriptorProto() {
} }
void ServiceDescriptorProto::SharedDtor() { void ServiceDescriptorProto::SharedDtor() {
if (name_ != &::google::protobuf::internal::kEmptyString) { if (name_ != &::google::protobuf::internal::GetEmptyString()) {
delete name_; delete name_;
} }
if (this != default_instance_) { if (this != default_instance_) {
@ -3706,7 +3706,7 @@ ServiceDescriptorProto* ServiceDescriptorProto::New() const {
void ServiceDescriptorProto::Clear() { void ServiceDescriptorProto::Clear() {
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (has_name()) { if (has_name()) {
if (name_ != &::google::protobuf::internal::kEmptyString) { if (name_ != &::google::protobuf::internal::GetEmptyString()) {
name_->clear(); name_->clear();
} }
} }
@ -3981,9 +3981,9 @@ MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from)
void MethodDescriptorProto::SharedCtor() { void MethodDescriptorProto::SharedCtor() {
_cached_size_ = 0; _cached_size_ = 0;
name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
input_type_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); input_type_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
output_type_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); output_type_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
options_ = NULL; options_ = NULL;
::memset(_has_bits_, 0, sizeof(_has_bits_)); ::memset(_has_bits_, 0, sizeof(_has_bits_));
} }
@ -3993,13 +3993,13 @@ MethodDescriptorProto::~MethodDescriptorProto() {
} }
void MethodDescriptorProto::SharedDtor() { void MethodDescriptorProto::SharedDtor() {
if (name_ != &::google::protobuf::internal::kEmptyString) { if (name_ != &::google::protobuf::internal::GetEmptyString()) {
delete name_; delete name_;
} }
if (input_type_ != &::google::protobuf::internal::kEmptyString) { if (input_type_ != &::google::protobuf::internal::GetEmptyString()) {
delete input_type_; delete input_type_;
} }
if (output_type_ != &::google::protobuf::internal::kEmptyString) { if (output_type_ != &::google::protobuf::internal::GetEmptyString()) {
delete output_type_; delete output_type_;
} }
if (this != default_instance_) { if (this != default_instance_) {
@ -4031,17 +4031,17 @@ MethodDescriptorProto* MethodDescriptorProto::New() const {
void MethodDescriptorProto::Clear() { void MethodDescriptorProto::Clear() {
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (has_name()) { if (has_name()) {
if (name_ != &::google::protobuf::internal::kEmptyString) { if (name_ != &::google::protobuf::internal::GetEmptyString()) {
name_->clear(); name_->clear();
} }
} }
if (has_input_type()) { if (has_input_type()) {
if (input_type_ != &::google::protobuf::internal::kEmptyString) { if (input_type_ != &::google::protobuf::internal::GetEmptyString()) {
input_type_->clear(); input_type_->clear();
} }
} }
if (has_output_type()) { if (has_output_type()) {
if (output_type_ != &::google::protobuf::internal::kEmptyString) { if (output_type_ != &::google::protobuf::internal::GetEmptyString()) {
output_type_->clear(); output_type_->clear();
} }
} }
@ -4396,12 +4396,12 @@ FileOptions::FileOptions(const FileOptions& from)
void FileOptions::SharedCtor() { void FileOptions::SharedCtor() {
_cached_size_ = 0; _cached_size_ = 0;
java_package_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); java_package_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
java_outer_classname_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); java_outer_classname_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
java_multiple_files_ = false; java_multiple_files_ = false;
java_generate_equals_and_hash_ = false; java_generate_equals_and_hash_ = false;
optimize_for_ = 1; optimize_for_ = 1;
go_package_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); go_package_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
cc_generic_services_ = false; cc_generic_services_ = false;
java_generic_services_ = false; java_generic_services_ = false;
py_generic_services_ = false; py_generic_services_ = false;
@ -4413,13 +4413,13 @@ FileOptions::~FileOptions() {
} }
void FileOptions::SharedDtor() { void FileOptions::SharedDtor() {
if (java_package_ != &::google::protobuf::internal::kEmptyString) { if (java_package_ != &::google::protobuf::internal::GetEmptyString()) {
delete java_package_; delete java_package_;
} }
if (java_outer_classname_ != &::google::protobuf::internal::kEmptyString) { if (java_outer_classname_ != &::google::protobuf::internal::GetEmptyString()) {
delete java_outer_classname_; delete java_outer_classname_;
} }
if (go_package_ != &::google::protobuf::internal::kEmptyString) { if (go_package_ != &::google::protobuf::internal::GetEmptyString()) {
delete go_package_; delete go_package_;
} }
if (this != default_instance_) { if (this != default_instance_) {
@ -4451,12 +4451,12 @@ void FileOptions::Clear() {
_extensions_.Clear(); _extensions_.Clear();
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (has_java_package()) { if (has_java_package()) {
if (java_package_ != &::google::protobuf::internal::kEmptyString) { if (java_package_ != &::google::protobuf::internal::GetEmptyString()) {
java_package_->clear(); java_package_->clear();
} }
} }
if (has_java_outer_classname()) { if (has_java_outer_classname()) {
if (java_outer_classname_ != &::google::protobuf::internal::kEmptyString) { if (java_outer_classname_ != &::google::protobuf::internal::GetEmptyString()) {
java_outer_classname_->clear(); java_outer_classname_->clear();
} }
} }
@ -4464,7 +4464,7 @@ void FileOptions::Clear() {
java_generate_equals_and_hash_ = false; java_generate_equals_and_hash_ = false;
optimize_for_ = 1; optimize_for_ = 1;
if (has_go_package()) { if (has_go_package()) {
if (go_package_ != &::google::protobuf::internal::kEmptyString) { if (go_package_ != &::google::protobuf::internal::GetEmptyString()) {
go_package_->clear(); go_package_->clear();
} }
} }
@ -5369,7 +5369,7 @@ void FieldOptions::SharedCtor() {
packed_ = false; packed_ = false;
lazy_ = false; lazy_ = false;
deprecated_ = false; deprecated_ = false;
experimental_map_key_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); experimental_map_key_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
weak_ = false; weak_ = false;
::memset(_has_bits_, 0, sizeof(_has_bits_)); ::memset(_has_bits_, 0, sizeof(_has_bits_));
} }
@ -5379,7 +5379,7 @@ FieldOptions::~FieldOptions() {
} }
void FieldOptions::SharedDtor() { void FieldOptions::SharedDtor() {
if (experimental_map_key_ != &::google::protobuf::internal::kEmptyString) { if (experimental_map_key_ != &::google::protobuf::internal::GetEmptyString()) {
delete experimental_map_key_; delete experimental_map_key_;
} }
if (this != default_instance_) { if (this != default_instance_) {
@ -5415,7 +5415,7 @@ void FieldOptions::Clear() {
lazy_ = false; lazy_ = false;
deprecated_ = false; deprecated_ = false;
if (has_experimental_map_key()) { if (has_experimental_map_key()) {
if (experimental_map_key_ != &::google::protobuf::internal::kEmptyString) { if (experimental_map_key_ != &::google::protobuf::internal::GetEmptyString()) {
experimental_map_key_->clear(); experimental_map_key_->clear();
} }
} }
@ -6788,7 +6788,7 @@ UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOp
void UninterpretedOption_NamePart::SharedCtor() { void UninterpretedOption_NamePart::SharedCtor() {
_cached_size_ = 0; _cached_size_ = 0;
name_part_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); name_part_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
is_extension_ = false; is_extension_ = false;
::memset(_has_bits_, 0, sizeof(_has_bits_)); ::memset(_has_bits_, 0, sizeof(_has_bits_));
} }
@ -6798,7 +6798,7 @@ UninterpretedOption_NamePart::~UninterpretedOption_NamePart() {
} }
void UninterpretedOption_NamePart::SharedDtor() { void UninterpretedOption_NamePart::SharedDtor() {
if (name_part_ != &::google::protobuf::internal::kEmptyString) { if (name_part_ != &::google::protobuf::internal::GetEmptyString()) {
delete name_part_; delete name_part_;
} }
if (this != default_instance_) { if (this != default_instance_) {
@ -6829,7 +6829,7 @@ UninterpretedOption_NamePart* UninterpretedOption_NamePart::New() const {
void UninterpretedOption_NamePart::Clear() { void UninterpretedOption_NamePart::Clear() {
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (has_name_part()) { if (has_name_part()) {
if (name_part_ != &::google::protobuf::internal::kEmptyString) { if (name_part_ != &::google::protobuf::internal::GetEmptyString()) {
name_part_->clear(); name_part_->clear();
} }
} }
@ -7057,12 +7057,12 @@ UninterpretedOption::UninterpretedOption(const UninterpretedOption& from)
void UninterpretedOption::SharedCtor() { void UninterpretedOption::SharedCtor() {
_cached_size_ = 0; _cached_size_ = 0;
identifier_value_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); identifier_value_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
positive_int_value_ = GOOGLE_ULONGLONG(0); positive_int_value_ = GOOGLE_ULONGLONG(0);
negative_int_value_ = GOOGLE_LONGLONG(0); negative_int_value_ = GOOGLE_LONGLONG(0);
double_value_ = 0; double_value_ = 0;
string_value_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); string_value_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
aggregate_value_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); aggregate_value_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
::memset(_has_bits_, 0, sizeof(_has_bits_)); ::memset(_has_bits_, 0, sizeof(_has_bits_));
} }
@ -7071,13 +7071,13 @@ UninterpretedOption::~UninterpretedOption() {
} }
void UninterpretedOption::SharedDtor() { void UninterpretedOption::SharedDtor() {
if (identifier_value_ != &::google::protobuf::internal::kEmptyString) { if (identifier_value_ != &::google::protobuf::internal::GetEmptyString()) {
delete identifier_value_; delete identifier_value_;
} }
if (string_value_ != &::google::protobuf::internal::kEmptyString) { if (string_value_ != &::google::protobuf::internal::GetEmptyString()) {
delete string_value_; delete string_value_;
} }
if (aggregate_value_ != &::google::protobuf::internal::kEmptyString) { if (aggregate_value_ != &::google::protobuf::internal::GetEmptyString()) {
delete aggregate_value_; delete aggregate_value_;
} }
if (this != default_instance_) { if (this != default_instance_) {
@ -7108,7 +7108,7 @@ UninterpretedOption* UninterpretedOption::New() const {
void UninterpretedOption::Clear() { void UninterpretedOption::Clear() {
if (_has_bits_[1 / 32] & (0xffu << (1 % 32))) { if (_has_bits_[1 / 32] & (0xffu << (1 % 32))) {
if (has_identifier_value()) { if (has_identifier_value()) {
if (identifier_value_ != &::google::protobuf::internal::kEmptyString) { if (identifier_value_ != &::google::protobuf::internal::GetEmptyString()) {
identifier_value_->clear(); identifier_value_->clear();
} }
} }
@ -7116,12 +7116,12 @@ void UninterpretedOption::Clear() {
negative_int_value_ = GOOGLE_LONGLONG(0); negative_int_value_ = GOOGLE_LONGLONG(0);
double_value_ = 0; double_value_ = 0;
if (has_string_value()) { if (has_string_value()) {
if (string_value_ != &::google::protobuf::internal::kEmptyString) { if (string_value_ != &::google::protobuf::internal::GetEmptyString()) {
string_value_->clear(); string_value_->clear();
} }
} }
if (has_aggregate_value()) { if (has_aggregate_value()) {
if (aggregate_value_ != &::google::protobuf::internal::kEmptyString) { if (aggregate_value_ != &::google::protobuf::internal::GetEmptyString()) {
aggregate_value_->clear(); aggregate_value_->clear();
} }
} }
@ -7546,8 +7546,8 @@ SourceCodeInfo_Location::SourceCodeInfo_Location(const SourceCodeInfo_Location&
void SourceCodeInfo_Location::SharedCtor() { void SourceCodeInfo_Location::SharedCtor() {
_cached_size_ = 0; _cached_size_ = 0;
leading_comments_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); leading_comments_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
trailing_comments_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); trailing_comments_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyString());
::memset(_has_bits_, 0, sizeof(_has_bits_)); ::memset(_has_bits_, 0, sizeof(_has_bits_));
} }
@ -7556,10 +7556,10 @@ SourceCodeInfo_Location::~SourceCodeInfo_Location() {
} }
void SourceCodeInfo_Location::SharedDtor() { void SourceCodeInfo_Location::SharedDtor() {
if (leading_comments_ != &::google::protobuf::internal::kEmptyString) { if (leading_comments_ != &::google::protobuf::internal::GetEmptyString()) {
delete leading_comments_; delete leading_comments_;
} }
if (trailing_comments_ != &::google::protobuf::internal::kEmptyString) { if (trailing_comments_ != &::google::protobuf::internal::GetEmptyString()) {
delete trailing_comments_; delete trailing_comments_;
} }
if (this != default_instance_) { if (this != default_instance_) {
@ -7590,12 +7590,12 @@ SourceCodeInfo_Location* SourceCodeInfo_Location::New() const {
void SourceCodeInfo_Location::Clear() { void SourceCodeInfo_Location::Clear() {
if (_has_bits_[2 / 32] & (0xffu << (2 % 32))) { if (_has_bits_[2 / 32] & (0xffu << (2 % 32))) {
if (has_leading_comments()) { if (has_leading_comments()) {
if (leading_comments_ != &::google::protobuf::internal::kEmptyString) { if (leading_comments_ != &::google::protobuf::internal::GetEmptyString()) {
leading_comments_->clear(); leading_comments_->clear();
} }
} }
if (has_trailing_comments()) { if (has_trailing_comments()) {
if (trailing_comments_ != &::google::protobuf::internal::kEmptyString) { if (trailing_comments_ != &::google::protobuf::internal::GetEmptyString()) {
trailing_comments_->clear(); trailing_comments_->clear();
} }
} }

File diff suppressed because it is too large Load Diff

@ -68,7 +68,7 @@ bool ParseNamedEnum(const EnumDescriptor* descriptor,
const string& NameOfEnum(const EnumDescriptor* descriptor, int value) { const string& NameOfEnum(const EnumDescriptor* descriptor, int value) {
const EnumValueDescriptor* d = descriptor->FindValueByNumber(value); const EnumValueDescriptor* d = descriptor->FindValueByNumber(value);
return (d == NULL ? kEmptyString : d->name()); return (d == NULL ? GetEmptyString() : d->name());
} }
// =================================================================== // ===================================================================
@ -771,7 +771,7 @@ string GeneratedMessageReflection::GetString(
} }
GOOGLE_LOG(FATAL) << "Can't get here."; GOOGLE_LOG(FATAL) << "Can't get here.";
return kEmptyString; // Make compiler happy. return GetEmptyString(); // Make compiler happy.
} }
} }
@ -790,7 +790,7 @@ const string& GeneratedMessageReflection::GetStringReference(
} }
GOOGLE_LOG(FATAL) << "Can't get here."; GOOGLE_LOG(FATAL) << "Can't get here.";
return kEmptyString; // Make compiler happy. return GetEmptyString(); // Make compiler happy.
} }
} }
@ -832,7 +832,7 @@ string GeneratedMessageReflection::GetRepeatedString(
} }
GOOGLE_LOG(FATAL) << "Can't get here."; GOOGLE_LOG(FATAL) << "Can't get here.";
return kEmptyString; // Make compiler happy. return GetEmptyString(); // Make compiler happy.
} }
} }
@ -850,7 +850,7 @@ const string& GeneratedMessageReflection::GetRepeatedStringReference(
} }
GOOGLE_LOG(FATAL) << "Can't get here."; GOOGLE_LOG(FATAL) << "Can't get here.";
return kEmptyString; // Make compiler happy. return GetEmptyString(); // Make compiler happy.
} }
} }

@ -47,7 +47,12 @@ double NaN() {
return std::numeric_limits<double>::quiet_NaN(); return std::numeric_limits<double>::quiet_NaN();
} }
const ::std::string kEmptyString; const ::std::string* empty_string_;
ProtobufOnceType empty_string_once_init_;
void InitEmptyString() {
empty_string_ = new std::string;
}
} // namespace internal } // namespace internal
} // namespace protobuf } // namespace protobuf

@ -41,6 +41,7 @@
#include <string> #include <string>
#include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/once.h>
namespace google { namespace google {
namespace protobuf { namespace protobuf {
namespace internal { namespace internal {
@ -59,8 +60,17 @@ namespace internal {
LIBPROTOBUF_EXPORT double Infinity(); LIBPROTOBUF_EXPORT double Infinity();
LIBPROTOBUF_EXPORT double NaN(); LIBPROTOBUF_EXPORT double NaN();
// Constant used for empty default strings. // Default empty string object. Don't use the pointer directly. Instead, call
LIBPROTOBUF_EXPORT extern const ::std::string kEmptyString; // GetEmptyString() to get the reference.
LIBPROTOBUF_EXPORT extern const ::std::string* empty_string_;
LIBPROTOBUF_EXPORT extern ProtobufOnceType empty_string_once_init_;
LIBPROTOBUF_EXPORT void InitEmptyString();
LIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyString() {
GoogleOnceInit(&empty_string_once_init_, &InitEmptyString);
return *empty_string_;
}
// Defined in generated_message_reflection.cc -- not actually part of the lite // Defined in generated_message_reflection.cc -- not actually part of the lite
// library. // library.

@ -383,7 +383,7 @@ class LIBPROTOBUF_EXPORT StringTypeHandlerBase {
static void Clear(string* value) { value->clear(); } static void Clear(string* value) { value->clear(); }
static void Merge(const string& from, string* to) { *to = from; } static void Merge(const string& from, string* to) { *to = from; }
static const Type& default_instance() { static const Type& default_instance() {
return ::google::protobuf::internal::kEmptyString; return ::google::protobuf::internal::GetEmptyString();
} }
}; };

Loading…
Cancel
Save