comparison libinterp/corefcn/load-path.cc @ 32131:fbadf4ce94c7

function cache to improve performance of function resolution * load-path.h, load-path.cc (load_path::signal_clear_fcn_cache, load_path::get_weak_n_updated): New static functions. (load_path::s_n_updated): New static variable. * variables.cc (Fclear): Call signal_clear_fcn_cache. * pt-eval.cc (tree_evaluator::remove_autoload): Call signal_clear_fcn_cache. * ov-base.h, ov-base.cc (octave_base_value::is_function_cache, octave_base_value::is_maybe_function, octave_base_value::has_function_cache, octave_base_value::get_cached_function, octave_base_value::fcn_cache_value): New virtual functions. * ov-fcn-handle.h, ov-fcn-handle.cc (simple_fcn_handle::get_cached_fcn, simple_fcn_handle::has_function_cache): New functions. (simple_fcn_handle::m_cache): New member variable. (octave_fcn_handle::octave_fcn_handle (const std::string&, octave_value)): New constructor. (octave_fcn_handle::get_cached_fcn, octave_fcn_handle::has_fcn_cache): New functions. * ov-fcn.h, ov-fcn.cc (class octave_fcn_cache): New class. (octave_function::is_compiled): New function. * ov.h, ov.cc (octave_value::is_function_cache, octave_value::has_function_cache, octave_value::get_cached_fcn, octave_value::is_maybe_function, octave_value::fcn_cache_value): New functions.
author Petter T. <petter.vilhelm@gmail.com>
date Sat, 17 Jun 2023 10:19:33 -0400
parents 7d663f770c5a
children 65781d62fee7
comparison
equal deleted inserted replaced
32130:dedc746ecd58 32131:fbadf4ce94c7
249 m_remove_hook ([=] (const std::string& dir) { this->execute_pkg_del (dir); }), 249 m_remove_hook ([=] (const std::string& dir) { this->execute_pkg_del (dir); }),
250 m_interpreter (interp), m_package_map (), m_top_level_package (), 250 m_interpreter (interp), m_package_map (), m_top_level_package (),
251 m_dir_info_list (), m_init_dirs (), m_command_line_path () 251 m_dir_info_list (), m_init_dirs (), m_command_line_path ()
252 { } 252 { }
253 253
254 std::atomic<octave_idx_type> load_path::s_n_updated;
255
254 void 256 void
255 load_path::initialize (bool set_initial_path) 257 load_path::initialize (bool set_initial_path)
256 { 258 {
257 s_sys_path = ""; 259 s_sys_path = "";
258 260
290 } 292 }
291 293
292 void 294 void
293 load_path::clear () 295 load_path::clear ()
294 { 296 {
297 signal_clear_fcn_cache ();
298
295 m_dir_info_list.clear (); 299 m_dir_info_list.clear ();
296 300
297 m_top_level_package.clear (); 301 m_top_level_package.clear ();
298 302
299 m_package_map.clear (); 303 m_package_map.clear ();
412 load_path::update () 416 load_path::update ()
413 { 417 {
414 // I don't see a better way to do this because we need to 418 // I don't see a better way to do this because we need to
415 // preserve the correct directory ordering for new files that 419 // preserve the correct directory ordering for new files that
416 // have appeared. 420 // have appeared.
421
422 signal_clear_fcn_cache ();
417 423
418 m_top_level_package.clear (); 424 m_top_level_package.clear ();
419 425
420 m_package_map.clear (); 426 m_package_map.clear ();
421 427