# HG changeset patch # User Markus Mützel # Date 1607873103 -3600 # Node ID e359e0fcd6e7389c96c8cb66b7a2e39a9f871562 # Parent eec0fe95576efd836b7ac8be3f1f7699ea73bf4e improve class_simple function handle function lookup (bug #59661) * ov-fcn-handle.cc (class_simple_fcn_handle::function_value): If function object is cached, use it. Otherwise, search for method using name and cached dispatch class. diff -r eec0fe95576e -r e359e0fcd6e7 libinterp/octave-value/ov-fcn-handle.cc --- a/libinterp/octave-value/ov-fcn-handle.cc Mon Dec 14 13:55:10 2020 -0500 +++ b/libinterp/octave-value/ov-fcn-handle.cc Sun Dec 13 16:25:03 2020 +0100 @@ -436,7 +436,22 @@ // scoping or overloads. octave_function * function_value (bool = false) { - return m_fcn.function_value (); + // FIXME: Shouldn't the lookup rules here match those used in the + // call method? + + if (m_fcn.is_defined ()) + return m_fcn.function_value (); + + symbol_table& symtab + = __get_symbol_table__ ("class_simple_fcn_handle::function_value"); + + // FIXME: is caching the correct thing to do? + // Cache this value so that the pointer will be valid as long as the + // function handle object is valid. + + m_fcn = symtab.find_method (m_name, m_dispatch_class); + + return m_fcn.is_defined () ? m_fcn.function_value () : nullptr; } octave_user_function * user_function_value (bool = false)