[Lldb-commits] [lldb] r353768 - Some cleanup after moving to std::make_shared

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 11 15:49:00 PST 2019


Author: jdevlieghere
Date: Mon Feb 11 15:48:59 2019
New Revision: 353768

URL: http://llvm.org/viewvc/llvm-project?rev=353768&view=rev
Log:
Some cleanup after moving to std::make_shared

Addresses Tatyana Krasnukha's feedback from D57990.

Modified:
    lldb/trunk/source/Core/IOHandler.cpp
    lldb/trunk/source/Target/Thread.cpp

Modified: lldb/trunk/source/Core/IOHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/IOHandler.cpp?rev=353768&r1=353767&r2=353768&view=diff
==============================================================================
--- lldb/trunk/source/Core/IOHandler.cpp (original)
+++ lldb/trunk/source/Core/IOHandler.cpp Mon Feb 11 15:48:59 2019
@@ -993,22 +993,15 @@ public:
 
   WindowSP CreateSubWindow(const char *name, const Rect &bounds,
                            bool make_active) {
-    WindowSP subwindow_sp;
-    if (m_window) {
-      subwindow_sp = std::make_shared<Window>(
-          name,
-          ::subwin(m_window, bounds.size.height, bounds.size.width,
-                         bounds.origin.y, bounds.origin.x),
-          true);
-      subwindow_sp->m_is_subwin = true;
-    } else {
-      subwindow_sp = std::make_shared<Window>(
-          name,
-          ::newwin(bounds.size.height, bounds.size.width, bounds.origin.y,
-                   bounds.origin.x),
-          true);
-      subwindow_sp->m_is_subwin = false;
-    }
+    auto get_window = [this, &bounds]() {
+      return m_window
+                 ? ::subwin(m_window, bounds.size.height, bounds.size.width,
+                            bounds.origin.y, bounds.origin.x)
+                 : ::newwin(bounds.size.height, bounds.size.width,
+                            bounds.origin.y, bounds.origin.x);
+    };
+    WindowSP subwindow_sp = std::make_shared<Window>(name, get_window(), true);
+    subwindow_sp->m_is_subwin = subwindow_sp.operator bool();
     subwindow_sp->m_parent = this;
     if (make_active) {
       m_prev_active_window_idx = m_curr_active_window_idx;

Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=353768&r1=353767&r2=353768&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Mon Feb 11 15:48:59 2019
@@ -1602,13 +1602,12 @@ void Thread::CalculateExecutionContext(E
 StackFrameListSP Thread::GetStackFrameList() {
   StackFrameListSP frame_list_sp;
   std::lock_guard<std::recursive_mutex> guard(m_frame_mutex);
-  if (m_curr_frames_sp) {
-    frame_list_sp = m_curr_frames_sp;
-  } else {
+
+  if (!m_curr_frames_sp)
     frame_list_sp =
         std::make_shared<StackFrameList>(*this, m_prev_frames_sp, true);
-    m_curr_frames_sp = frame_list_sp;
-  }
+
+  frame_list_sp = m_curr_frames_sp;
   return frame_list_sp;
 }
 




More information about the lldb-commits mailing list