aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/generated_message_util.h
diff options
context:
space:
mode:
authorGravatar xiaofeng@google.com <xiaofeng@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2014-02-13 22:09:48 +0000
committerGravatar xiaofeng@google.com <xiaofeng@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2014-02-13 22:09:48 +0000
commit37c7426b4782ea01f40875b30782ab5ef0ac99b6 (patch)
tree47128be3794fb42501951e637bb9185dba96497f /src/google/protobuf/generated_message_util.h
parentf0b6a5cfeb5f6347c34975446bda08e0c20c9902 (diff)
Replace kEmptyString wth OnceInit initialized string*
Diffstat (limited to 'src/google/protobuf/generated_message_util.h')
-rw-r--r--src/google/protobuf/generated_message_util.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/google/protobuf/generated_message_util.h b/src/google/protobuf/generated_message_util.h
index b2fb8f0b..098f3219 100644
--- a/src/google/protobuf/generated_message_util.h
+++ b/src/google/protobuf/generated_message_util.h
@@ -41,6 +41,7 @@
#include <string>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/stubs/once.h>
namespace google {
namespace protobuf {
namespace internal {
@@ -59,8 +60,17 @@ namespace internal {
LIBPROTOBUF_EXPORT double Infinity();
LIBPROTOBUF_EXPORT double NaN();
-// Constant used for empty default strings.
-LIBPROTOBUF_EXPORT extern const ::std::string kEmptyString;
+// Default empty string object. Don't use the pointer directly. Instead, call
+// 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
// library.