Simplify GetGlobalProperties functions of Thread/Process/Target
Summary:
"Initialization of function-local statics is guaranteed to occur only once even when called from
multiple threads, and may be more efficient than the equivalent code using std::call_once."
<http://en.cppreference.com/w/cpp/thread/call_once>
I'd add that it's also more readable.
Reviewers: clayborg, zturner
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D17710
llvm-svn: 284601
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index f4a9119..3fb5300 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -2643,11 +2643,8 @@
const TargetPropertiesSP &Target::GetGlobalProperties() {
// NOTE: intentional leak so we don't crash if global destructor chain gets
// called as other threads still use the result of this function
- static TargetPropertiesSP *g_settings_sp_ptr = nullptr;
- static std::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
- g_settings_sp_ptr = new TargetPropertiesSP(new TargetProperties(nullptr));
- });
+ static TargetPropertiesSP *g_settings_sp_ptr =
+ new TargetPropertiesSP(new TargetProperties(nullptr));
return *g_settings_sp_ptr;
}