changeset 30105:67994b92a613

eliminate redundant storage of parent function name in function objects * ov-usr-fcn.h, ov-usr-fcn.cc (octave_user_function::m_parent_name): Delete member variable and all uses. (octave_user_function::stash_parent_fcn_name): Delete member function and all uses. (octave_user_function::parent_fcn_name): Get parent name from parent scope.
author John W. Eaton <jwe@octave.org>
date Wed, 01 Sep 2021 23:50:07 -0400
parents 761210f338c7
children b08749cb3261
files libinterp/corefcn/symscope.cc libinterp/octave-value/ov-usr-fcn.cc libinterp/octave-value/ov-usr-fcn.h libinterp/parse-tree/oct-parse.yy libinterp/parse-tree/pt-fcn-handle.cc
diffstat 5 files changed, 8 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/symscope.cc	Wed Sep 01 16:57:05 2021 -0400
+++ b/libinterp/corefcn/symscope.cc	Wed Sep 01 23:50:07 2021 -0400
@@ -200,14 +200,6 @@
   symbol_scope_rep::cache_parent_fcn_names (const std::list<std::string>& names)
   {
     m_parent_fcn_names = names;
-
-    if (m_code && m_code->is_user_function ())
-      {
-        octave_user_function *fcn
-          = dynamic_cast<octave_user_function *> (m_code);
-
-        fcn->stash_parent_fcn_name (names.front ());
-      }
   }
 
   void
--- a/libinterp/octave-value/ov-usr-fcn.cc	Wed Sep 01 16:57:05 2021 -0400
+++ b/libinterp/octave-value/ov-usr-fcn.cc	Wed Sep 01 23:50:07 2021 -0400
@@ -218,7 +218,7 @@
     m_param_list (pl), m_ret_list (rl),
     m_lead_comm (), m_trail_comm (),
     m_location_line (0), m_location_column (0),
-    m_parent_name (), m_system_fcn_file (false),
+    m_system_fcn_file (false),
     m_num_named_args (m_param_list ? m_param_list->length () : 0),
     m_subfunction (false), m_inline_function (false),
     m_anonymous_function (false), m_nested_function (false),
@@ -591,7 +591,6 @@
        { "col", m_location_column },
        { "end_line", m_end_location_line },
        { "end_col", m_end_location_column },
-       { "parent_name", m_parent_name },
        { "system_fcn_file", m_system_fcn_file },
        { "num_named_args", m_num_named_args },
        { "subfunction", m_subfunction },
--- a/libinterp/octave-value/ov-usr-fcn.h	Wed Sep 01 16:57:05 2021 -0400
+++ b/libinterp/octave-value/ov-usr-fcn.h	Wed Sep 01 23:50:07 2021 -0400
@@ -252,8 +252,6 @@
 
   void maybe_relocate_end (void);
 
-  void stash_parent_fcn_name (const std::string& p) { m_parent_name = p; }
-
   void stash_parent_fcn_scope (const octave::symbol_scope& ps);
 
   void stash_leading_comment (octave::comment_list *lc) { m_lead_comm = lc; }
@@ -262,7 +260,12 @@
 
   std::string profiler_name (void) const;
 
-  std::string parent_fcn_name (void) const { return m_parent_name; }
+  std::string parent_fcn_name (void) const
+  {
+    octave::symbol_scope pscope = parent_fcn_scope ();
+
+    return pscope.fcn_name ();
+  }
 
   octave::symbol_scope parent_fcn_scope (void) const
   {
@@ -436,9 +439,6 @@
   int m_end_location_line;
   int m_end_location_column;
 
-  // The name of the parent function, if any.
-  std::string m_parent_name;
-
   // True if this function came from a file that is considered to be a
   // system function.  This affects whether we check the time stamp
   // on the file to see if it has changed.
--- a/libinterp/parse-tree/oct-parse.yy	Wed Sep 01 16:57:05 2021 -0400
+++ b/libinterp/parse-tree/oct-parse.yy	Wed Sep 01 23:50:07 2021 -0400
@@ -4205,7 +4205,6 @@
         if (m_curr_fcn_depth > 0 || m_parsing_subfunctions)
           {
             fcn->stash_fcn_location (l, c);
-            fcn->stash_parent_fcn_name (m_lexer.m_fcn_file_name);
 
             octave_value ov_fcn (fcn);
 
@@ -4231,7 +4230,7 @@
                   fcn_scope.set_primary_parent (m_primary_fcn_scope);
                 m_primary_fcn_scope.install_subfunction (fcn_nm, ov_fcn);
 
-                // Prepend name of primary fucntion to list of parent
+                // Prepend name of primary function to list of parent
                 // functions (if any) for subfunction.
 
                 std::list<std::string> plst
--- a/libinterp/parse-tree/pt-fcn-handle.cc	Wed Sep 01 16:57:05 2021 -0400
+++ b/libinterp/parse-tree/pt-fcn-handle.cc	Wed Sep 01 23:50:07 2021 -0400
@@ -169,7 +169,6 @@
             new_scope.set_nesting_depth (parent_scope.nesting_depth () + 1);
           }
 
-        af->stash_parent_fcn_name (curr_fcn->name ());
         af->stash_dir_name (curr_fcn->dir_name ());
 
         new_scope.cache_fcn_file_name (curr_fcn->fcn_file_name ());