# HG changeset patch # User Rik # Date 1601388845 25200 # Node ID 6ec04c206ac464c439c07032232937d9a946dfba # Parent aef839f40da2469dc287acab95d4ee8f0e7ea725 Replace unwind_protect with more efficient constructs (bug #59192). * dynamic-ld.cc, sparse.cc, __init_gnuplot__.cc: Replace unwind_protect frame and protect_var() call for a simple variable with unwind_protect_var(). diff -r aef839f40da2 -r 6ec04c206ac4 libinterp/corefcn/dynamic-ld.cc --- a/libinterp/corefcn/dynamic-ld.cc Tue Sep 29 06:59:13 2020 -0700 +++ b/libinterp/corefcn/dynamic-ld.cc Tue Sep 29 07:14:05 2020 -0700 @@ -152,11 +152,7 @@ { octave_function *retval = nullptr; - unwind_protect frame; - - frame.protect_var (m_doing_load); - - m_doing_load = true; + octave::unwind_protect_var restore_var (m_doing_load, true); dynamic_library oct_file = m_loaded_shlibs.find_file (file_name); @@ -234,11 +230,7 @@ const std::string& file_name, bool /*relative*/) { - unwind_protect frame; - - frame.protect_var (m_doing_load); - - m_doing_load = true; + octave::unwind_protect_var restore_var (m_doing_load, true); dynamic_library mex_file = m_loaded_shlibs.find_file (file_name); diff -r aef839f40da2 -r 6ec04c206ac4 libinterp/corefcn/sparse.cc --- a/libinterp/corefcn/sparse.cc Tue Sep 29 06:59:13 2020 -0700 +++ b/libinterp/corefcn/sparse.cc Tue Sep 29 07:14:05 2020 -0700 @@ -152,9 +152,7 @@ octave_value retval; // Temporarily disable sparse_auto_mutate if set (it's obsolete anyway). - octave::unwind_protect frame; - frame.protect_var (Vsparse_auto_mutate); - Vsparse_auto_mutate = false; + octave::unwind_protect_var restore_var (Vsparse_auto_mutate, false); if (nargin == 1) { diff -r aef839f40da2 -r 6ec04c206ac4 libinterp/dldfcn/__init_gnuplot__.cc --- a/libinterp/dldfcn/__init_gnuplot__.cc Tue Sep 29 06:59:13 2020 -0700 +++ b/libinterp/dldfcn/__init_gnuplot__.cc Tue Sep 29 07:14:05 2020 -0700 @@ -111,10 +111,8 @@ // Prevent recursion if (! drawnow_executing) { - octave::unwind_protect frame; - frame.protect_var (drawnow_executing); + octave::unwind_protect_var restore_var (drawnow_executing, true); - drawnow_executing = true; octave_value_list args; args(0) = go.get_handle ().as_octave_value (); octave::feval ("__gnuplot_drawnow__", args);