# HG changeset patch # User John W. Eaton # Date 1515078563 18000 # Node ID 6c31b03769082721e7feacd873546cebd2b76e76 # Parent 0e66dda0c1d6771284ac758c185491509b441795 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. diff -r 0e66dda0c1d6 -r 6c31b0376908 libinterp/corefcn/symrec.cc --- 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; diff -r 0e66dda0c1d6 -r 6c31b0376908 libinterp/corefcn/symrec.h --- 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 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; }; }