Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Unified Diff: third_party/protobuf/src/google/protobuf/generated_message_util.h

Issue 164743002: Replace kEmptyString with OnceInit initialized string* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/protobuf/src/google/protobuf/generated_message_util.h
diff --git a/third_party/protobuf/src/google/protobuf/generated_message_util.h b/third_party/protobuf/src/google/protobuf/generated_message_util.h
index b2fb8f0be2a2e42eb1adf643f7a358432a2b89fc..098f3219806df4cb4333f384cef9609a1ddf3de5 100644
--- a/third_party/protobuf/src/google/protobuf/generated_message_util.h
+++ b/third_party/protobuf/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.

Powered by Google App Engine
This is Rietveld 408576698