diff -r f89864234b5d src/load-path.cc --- a/src/load-path.cc Sun Mar 29 22:18:21 2009 -0700 +++ b/src/load-path.cc Mon Mar 30 16:45:18 2009 +0200 @@ -25,6 +25,7 @@ #endif #include +#include #include "dir-ops.h" #include "file-ops.h" @@ -1095,6 +1096,9 @@ load_path::do_find_file (const std::string& file) const { std::string retval; + static std::map memo; + if (memo.find(file) != memo.end()) return memo[file]; + if (memo.size()>32) memo.clear(); if (file.find_first_of (file_ops::dir_sep_chars ()) != std::string::npos) { @@ -1103,8 +1107,10 @@ { file_stat fs (file); - if (fs.exists ()) - return file; + if (fs.exists ()) { + memo[file] = file; + return memo[file]; + } } else { @@ -1116,8 +1122,10 @@ file_stat fs (tfile); - if (fs.exists ()) - return tfile; + if (fs.exists ()) { + memo[file] = tfile; + return memo[file]; + } } } } @@ -1133,12 +1141,13 @@ for (octave_idx_type i = 0; i < len; i++) { - if (all_files[i] == file) - return file_ops::concat (p->dir_name, file); + if (all_files[i] == file) { + memo[file]= file_ops::concat (p->dir_name, file); + return memo[file]; + } } } } - return retval; }