diff options
| author | Pavel Labath <labath@google.com> | 2016-10-19 15:12:45 +0000 |
|---|---|---|
| committer | Pavel Labath <labath@google.com> | 2016-10-19 15:12:45 +0000 |
| commit | 5f05ea84d58d2b3044e5fad164bd7ebb22aff348 (patch) | |
| tree | 01c59e4597a57a510af44860eb84423947c1d1a6 /lldb/source/Target/Process.cpp | |
| parent | ce30b1c78ef3b7d6e5426b4ed778eccd68162c7e (diff) | |
| download | bcm5719-llvm-5f05ea84d58d2b3044e5fad164bd7ebb22aff348.tar.gz bcm5719-llvm-5f05ea84d58d2b3044e5fad164bd7ebb22aff348.zip | |
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
Diffstat (limited to 'lldb/source/Target/Process.cpp')
| -rw-r--r-- | lldb/source/Target/Process.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 4448ed0720d..b539ea3a2ee 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -812,11 +812,8 @@ Process::~Process() { const ProcessPropertiesSP &Process::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 ProcessPropertiesSP *g_settings_sp_ptr = nullptr; - static std::once_flag g_once_flag; - std::call_once(g_once_flag, []() { - g_settings_sp_ptr = new ProcessPropertiesSP(new ProcessProperties(nullptr)); - }); + static ProcessPropertiesSP *g_settings_sp_ptr = + new ProcessPropertiesSP(new ProcessProperties(nullptr)); return *g_settings_sp_ptr; } |

