diff libinterp/corefcn/symscope.cc @ 30108:3efce22b7350

eliminate duplicate parent function name info in symbol scope objects * symscope.h, symscope.cc (symbol_scope_rep::m_parent_fcn_names): Delete member variable. (symbol_scope_rep::cache_parent_fcn_names): Delete function and all uses. (symbol_scope_rep::parent_fcn_names): Generate list of parent function names from parent scope info as needed.
author John W. Eaton <jwe@octave.org>
date Thu, 02 Sep 2021 11:20:53 -0400
parents 67994b92a613
children 91c6288781ba 796f54d4ddbf
line wrap: on
line diff
--- a/libinterp/corefcn/symscope.cc	Thu Sep 02 11:17:45 2021 -0400
+++ b/libinterp/corefcn/symscope.cc	Thu Sep 02 11:20:53 2021 -0400
@@ -196,10 +196,21 @@
       }
   }
 
-  void
-  symbol_scope_rep::cache_parent_fcn_names (const std::list<std::string>& names)
+  std::list<std::string>
+  symbol_scope_rep::parent_fcn_names (void) const
   {
-    m_parent_fcn_names = names;
+    std::list<std::string> retval;
+
+    auto pscope = parent_scope_rep ();
+
+    while (pscope)
+      {
+        retval.push_back (pscope->fcn_name ());
+
+        pscope = pscope->parent_scope_rep ();
+      }
+
+    return retval;
   }
 
   void
@@ -319,14 +330,8 @@
         m_is_static = true;
       }
 
-    std::list<std::string> plst = parent_fcn_names ();
-    plst.push_front (m_fcn_name);
-
     for (auto& scope_obj : m_children)
-      {
-        scope_obj.cache_parent_fcn_names (plst);
-        scope_obj.update_nest ();
-      }
+      scope_obj.update_nest ();
   }
 
   bool symbol_scope_rep::look_nonlocal (const std::string& name,