changeset 27506:17cc96fc55d6

eliminate some unnecessary unwind_protect actions * interpreter.cc (interpreter::parse_fcn_file): Don't save and restore command_editor::input_stream or command_history::ignoring_entries. Use unwind_action instead of unwind_protect frame. (safe_fclose): Delete.
author John W. Eaton <jwe@octave.org>
date Thu, 10 Oct 2019 16:27:57 -0400
parents c409d16b7190
children 2d537a089e5d
files libinterp/corefcn/interpreter.cc
diffstat 1 files changed, 4 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/interpreter.cc	Thu Oct 10 13:54:14 2019 -0400
+++ b/libinterp/corefcn/interpreter.cc	Thu Oct 10 16:27:57 2019 -0400
@@ -1416,13 +1416,6 @@
                              warn_for);
   }
 
-  static void
-  safe_fclose (FILE *f)
-  {
-    if (f)
-      fclose (static_cast<FILE *> (f));
-  }
-
   octave_value
   interpreter::parse_fcn_file (const std::string& full_file,
                                const std::string& file,
@@ -1436,19 +1429,6 @@
   {
     octave_value retval;
 
-    unwind_protect frame;
-
-    // Open function file and parse.
-
-    FILE *in_stream = command_editor::get_input_stream ();
-
-    frame.add_fcn (command_editor::set_input_stream, in_stream);
-
-    frame.add_fcn (command_history::ignore_entries,
-                   command_history::ignoring_entries ());
-
-    command_history::ignore_entries ();
-
     FILE *ffile = nullptr;
 
     if (! full_file.empty ())
@@ -1456,7 +1436,10 @@
 
     if (ffile)
       {
-        frame.add_fcn (safe_fclose, ffile);
+        unwind_action act ([ffile] (void)
+                           {
+                             fclose (ffile);
+                           });
 
         parser parser (ffile, *this);