comparison src/symtab.cc @ 9413:5cd879a0d8c4

speed-up function call by caching its name lookup
author Jaroslav Hajek <highegg@gmail.com>
date Wed, 01 Jul 2009 10:42:58 +0200
parents d8f9588c6ba1
children 2d73b19c5507
comparison
equal deleted inserted replaced
9412:ddcc0da700b8 9413:5cd879a0d8c4
102 bool& args_evaluated) const 102 bool& args_evaluated) const
103 { 103 {
104 octave_value retval; 104 octave_value retval;
105 105
106 if (is_global ()) 106 if (is_global ())
107 return symbol_table::global_varref (name ()); 107 retval = symbol_table::global_varref (name ());
108 else 108 else
109 { 109 {
110 octave_value val = varval (); 110 retval = varval ();
111 111
112 if (val.is_defined ()) 112 if (retval.is_undefined ())
113 return val; 113 {
114 } 114 // Use cached fcn_info pointer if possible.
115 115 if (rep->finfo)
116 return symbol_table::find_function (name (), args, arg_names, 116 retval = rep->finfo->find (args, arg_names,
117 evaluated_args, args_evaluated); 117 evaluated_args, args_evaluated);
118 else
119 {
120 retval = symbol_table::find_function (name (), args, arg_names,
121 evaluated_args, args_evaluated);
122
123 if (retval.is_defined ())
124 rep->finfo = get_fcn_info (name ());
125 }
126 }
127 }
128
129 return retval;
118 } 130 }
119 131
120 // Check the load path to see if file that defined this is still 132 // Check the load path to see if file that defined this is still
121 // visible. If the file is no longer visible, then erase the 133 // visible. If the file is no longer visible, then erase the
122 // definition and move on. If the file is visible, then we also 134 // definition and move on. If the file is visible, then we also