Mercurial > hg > octave-kai
changeset 8691:7838271ee25c
symtab.cc (symbol_table::fcn_info::fcn_info_rep::find): avoid recursive call
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 05 Feb 2009 19:58:04 -0500 |
parents | 6e9887f9cf9f |
children | 54227442f7ed |
files | src/ChangeLog src/symtab.cc src/symtab.h |
diffstat | 3 files changed, 31 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2009-02-05 John W. Eaton <jwe@octave.org> + * symtab.cc (symbol_table::fcn_info::cn_info_rep::xfind): + New function. + (symbol_table::fcn_info::cn_info_rep::find): + Use it to avoid recursive call. + * graphics.cc (Fdrawnow): Return after errors. Don't strip trailing directory separator from name used in call to file_stat.
--- a/src/symtab.cc +++ b/src/symtab.cc @@ -488,8 +488,27 @@ (tree_argument_list *args, const string_vector& arg_names, octave_value_list& evaluated_args, bool& args_evaluated) { - static bool deja_vu = false; + octave_value retval = xfind (args, arg_names, evaluated_args, args_evaluated); + + if (! retval.is_defined ()) + { + // It is possible that the user created a file on the fly since + // the last prompt or chdir, so try updating the load path and + // searching again. + + load_path::update (); + retval = xfind (args, arg_names, evaluated_args, args_evaluated); + } + + return retval; +} + +octave_value +symbol_table::fcn_info::fcn_info_rep::xfind + (tree_argument_list *args, const string_vector& arg_names, + octave_value_list& evaluated_args, bool& args_evaluated) +{ // Subfunction. I think it only makes sense to check for // subfunctions if we are currently executing a function defined // from a .m file. @@ -672,29 +691,9 @@ if (fcn.is_defined ()) return fcn; - // Built-in function. - - if (built_in_function.is_defined ()) - return built_in_function; - - // At this point, we failed to find anything. It is possible that - // the user created a file on the fly since the last prompt or - // chdir, so try updating the load path and searching again. - - octave_value retval; + // Built-in function (might be undefined). - if (! deja_vu) - { - load_path::update (); - - deja_vu = true; - - retval = find (args, arg_names, evaluated_args, args_evaluated); - } - - deja_vu = false; - - return retval; + return built_in_function; } octave_value