# HG changeset patch # User Rik # Date 1601466919 25200 # Node ID 473ee93cf1eaee2c62c103836670d2963402c622 # Parent a98fd0657e35fddc14af9f09936b26c8115131cd Replace unwind_protect with more efficient constructs (bug #59192). * call-stack.cc, input.cc: Replace frame.add_fcn () instances with unwind_action<> object. diff -r a98fd0657e35 -r 473ee93cf1ea libinterp/corefcn/call-stack.cc --- a/libinterp/corefcn/call-stack.cc Wed Sep 30 04:16:37 2020 -0700 +++ b/libinterp/corefcn/call-stack.cc Wed Sep 30 04:55:19 2020 -0700 @@ -968,14 +968,14 @@ // implement this option there so that the variables are never // stored at all. - unwind_protect frame; - // Set up temporary scope. symbol_scope tmp_scope ("$dummy_scope$"); push (tmp_scope); - frame.add_method (*this, &call_stack::pop); + + octave::unwind_action restore_scope + ([] (auto& self) { self->pop (); }, this); feval ("load", octave_value (file_name), 0); diff -r a98fd0657e35 -r 473ee93cf1ea libinterp/corefcn/input.cc --- a/libinterp/corefcn/input.cc Wed Sep 30 04:16:37 2020 -0700 +++ b/libinterp/corefcn/input.cc Wed Sep 30 04:55:19 2020 -0700 @@ -926,8 +926,11 @@ "converting from codepage '%s' to UTF-8: %s", encoding.c_str (), std::strerror (errno)); - unwind_protect frame; - frame.add_fcn (::free, static_cast (utf8_str)); + octave::unwind_action free_utf8_str + ([] (const auto utf8_str_ptr) + { + ::free (utf8_str_ptr); + }, static_cast (utf8_str)); src_str = std::string (reinterpret_cast (utf8_str), length); }