aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/generated_message_util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/generated_message_util.cc')
-rw-r--r--src/google/protobuf/generated_message_util.cc27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/google/protobuf/generated_message_util.cc b/src/google/protobuf/generated_message_util.cc
index dac8ca90..e0241361 100644
--- a/src/google/protobuf/generated_message_util.cc
+++ b/src/google/protobuf/generated_message_util.cc
@@ -57,6 +57,12 @@ namespace google {
namespace protobuf {
namespace internal {
+void DestroyMessage(const void* message) {
+ static_cast<const MessageLite*>(message)->~MessageLite();
+}
+void DestroyString(const void* s) { static_cast<const string*>(s)->~string(); }
+
+ExplicitlyConstructed<std::string> fixed_address_empty_string;
double Infinity() {
return std::numeric_limits<double>::infinity();
@@ -65,14 +71,15 @@ double NaN() {
return std::numeric_limits<double>::quiet_NaN();
}
-ExplicitlyConstructed<::std::string> fixed_address_empty_string;
-GOOGLE_PROTOBUF_DECLARE_ONCE(empty_string_once_init_);
-
-void DeleteEmptyString() { fixed_address_empty_string.Destruct(); }
-
-void InitEmptyString() {
+static bool InitProtobufDefaultsImpl() {
fixed_address_empty_string.DefaultConstruct();
- OnShutdown(&DeleteEmptyString);
+ OnShutdownDestroyString(fixed_address_empty_string.get_mutable());
+ return true;
+}
+
+void InitProtobufDefaults() {
+ static bool is_inited = InitProtobufDefaultsImpl();
+ (void)is_inited;
}
size_t StringSpaceUsedExcludingSelfLong(const string& str) {
@@ -86,12 +93,6 @@ size_t StringSpaceUsedExcludingSelfLong(const string& str) {
}
}
-
-
-void InitProtobufDefaults() {
- GetEmptyString();
-}
-
template <typename T>
const T& Get(const void* ptr) {
return *static_cast<const T*>(ptr);