From 796ac80b863ed92c3d8bcc296f678ff416afc8a8 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 11 Feb 2019 23:13:08 +0000 Subject: Use std::make_shared in LLDB (NFC) Unlike std::make_unique, which is only available since C++14, std::make_shared is available since C++11. Not only is std::make_shared a lot more readable compared to ::reset(new), it also performs a single heap allocation for the object and control block. Differential revision: https://reviews.llvm.org/D57990 llvm-svn: 353764 --- .../ScriptInterpreter/Python/ScriptInterpreterPython.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp') diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index 89f789f..294c4b0 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -811,7 +812,7 @@ bool ScriptInterpreterPython::ExecuteOneLine( join_read_thread = true; FILE *outfile_handle = fdopen(pipe.ReleaseWriteFileDescriptor(), "w"); - output_file_sp.reset(new StreamFile(outfile_handle, true)); + output_file_sp = std::make_shared(outfile_handle, true); error_file_sp = output_file_sp; if (outfile_handle) ::setbuf(outfile_handle, nullptr); @@ -827,12 +828,12 @@ bool ScriptInterpreterPython::ExecuteOneLine( debugger.AdoptTopIOHandlerFilesIfInvalid(input_file_sp, output_file_sp, error_file_sp); } else { - input_file_sp.reset(new StreamFile()); + input_file_sp = std::make_shared(); FileSystem::Instance().Open(input_file_sp->GetFile(), FileSpec(FileSystem::DEV_NULL), File::eOpenOptionRead); - output_file_sp.reset(new StreamFile()); + output_file_sp = std::make_shared(); FileSystem::Instance().Open(output_file_sp->GetFile(), FileSpec(FileSystem::DEV_NULL), File::eOpenOptionWrite); @@ -2220,7 +2221,7 @@ bool ScriptInterpreterPython::GetScriptedSummary( } if (new_callee && old_callee != new_callee) - callee_wrapper_sp.reset(new StructuredPythonObject(new_callee)); + callee_wrapper_sp = std::make_shared(new_callee); return ret_val; } @@ -2879,7 +2880,7 @@ bool ScriptInterpreterPython::LoadScriptingModule( ScriptInterpreter::eScriptReturnTypeOpaqueObject, &module_pyobj) && module_pyobj) - module_sp->reset(new StructuredPythonObject(module_pyobj)); + *module_sp = std::make_shared(module_pyobj); } return true; -- cgit v1.1