Some cleanup after moving to std::make_shared

Addresses Tatyana Krasnukha's feedback from D57990.

llvm-svn: 353768
This commit is contained in:
Jonas Devlieghere 2019-02-11 23:48:59 +00:00
parent cf39dd44b8
commit c6091d2bed
2 changed files with 13 additions and 21 deletions

View File

@ -993,22 +993,15 @@ public:
WindowSP CreateSubWindow(const char *name, const Rect &bounds, WindowSP CreateSubWindow(const char *name, const Rect &bounds,
bool make_active) { bool make_active) {
WindowSP subwindow_sp; auto get_window = [this, &bounds]() {
if (m_window) { return m_window
subwindow_sp = std::make_shared<Window>( ? ::subwin(m_window, bounds.size.height, bounds.size.width,
name, bounds.origin.y, bounds.origin.x)
::subwin(m_window, bounds.size.height, bounds.size.width, : ::newwin(bounds.size.height, bounds.size.width,
bounds.origin.y, bounds.origin.x), bounds.origin.y, bounds.origin.x);
true); };
subwindow_sp->m_is_subwin = true; WindowSP subwindow_sp = std::make_shared<Window>(name, get_window(), true);
} else { subwindow_sp->m_is_subwin = subwindow_sp.operator bool();
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;
}
subwindow_sp->m_parent = this; subwindow_sp->m_parent = this;
if (make_active) { if (make_active) {
m_prev_active_window_idx = m_curr_active_window_idx; m_prev_active_window_idx = m_curr_active_window_idx;

View File

@ -1602,13 +1602,12 @@ void Thread::CalculateExecutionContext(ExecutionContext &exe_ctx) {
StackFrameListSP Thread::GetStackFrameList() { StackFrameListSP Thread::GetStackFrameList() {
StackFrameListSP frame_list_sp; StackFrameListSP frame_list_sp;
std::lock_guard<std::recursive_mutex> guard(m_frame_mutex); std::lock_guard<std::recursive_mutex> guard(m_frame_mutex);
if (m_curr_frames_sp) {
frame_list_sp = m_curr_frames_sp; if (!m_curr_frames_sp)
} else {
frame_list_sp = frame_list_sp =
std::make_shared<StackFrameList>(*this, m_prev_frames_sp, true); 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; return frame_list_sp;
} }