changeset 24519:6c31b0376908

move part of symbol_record::find to header file to allow inlining * symrec.h, symrec.cc (symbol_record::find_function): New private function, defined in symrec.cc because it requires the symbol_table object. (symbol_record::find): Move body to header file so finding a variable can be inlined. Call find_function if that fails.
author John W. Eaton <jwe@octave.org>
date Thu, 04 Jan 2018 10:09:23 -0500
parents 0e66dda0c1d6
children c5c11b07598a
files libinterp/corefcn/symrec.cc libinterp/corefcn/symrec.h
diffstat 2 files changed, 21 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/symrec.cc	Thu Jan 04 11:23:43 2018 -0800
+++ b/libinterp/corefcn/symrec.cc	Thu Jan 04 10:09:23 2018 -0500
@@ -102,26 +102,17 @@
   }
 
   octave_value
-  symbol_record::find (context_id context,
-                       const octave_value_list& args) const
+  symbol_record::find_function (const std::string& name,
+                                const octave_value_list& args) const
   {
-    octave_value retval;
+    // FIXME: it would be better if the symbol_record object did not
+    // look back to the symbol_table when the value is undefined.  More
+    // refactoring is needed...
 
     symbol_table& symtab
-      = __get_symbol_table__ ("symbol_record::find");
-
-    retval = varval (context);
+      = __get_symbol_table__ ("symbol_record::find_function");
 
-    if (retval.is_undefined ())
-      {
-        // FIXME
-        retval = symtab.find_function (name (), args);
-
-        if (retval.is_defined ())
-          return retval;
-      }
-
-    return retval;
+    return symtab.find_function (name, args);
   }
 
   octave_value symbol_record::dummy_octave_value;
--- a/libinterp/corefcn/symrec.h	Thu Jan 04 11:23:43 2018 -0800
+++ b/libinterp/corefcn/symrec.h	Thu Jan 04 10:09:23 2018 -0500
@@ -554,7 +554,15 @@
 
     octave_value
     find (context_id context,
-          const octave_value_list& args = octave_value_list ()) const;
+          const octave_value_list& args = octave_value_list ()) const
+    {
+      octave_value retval = varval (context);
+
+      if (retval.is_undefined ())
+        return find_function (name (), args);
+
+      return retval;
+    }
 
     void assign (const octave_value& value, context_id context)
     {
@@ -658,12 +666,15 @@
 
   private:
 
-    static octave_value dummy_octave_value;
-
     std::shared_ptr<symbol_record_rep> m_rep;
 
     // NEW_REP must be dynamically allocated or nullptr.
     symbol_record (symbol_record_rep *new_rep) : m_rep (new_rep) { }
+
+    octave_value find_function (const std::string& name,
+                                const octave_value_list& args) const;
+
+    static octave_value dummy_octave_value;
   };
 }