Mercurial > octave-nkf
changeset 2286:c0eed36e660d
[project @ 1996-05-31 04:41:50 by jwe]
author | jwe |
---|---|
date | Fri, 31 May 1996 04:43:11 +0000 |
parents | 3e0a2661f0a0 |
children | 0e065eb7e838 |
files | src/fn-cache.cc src/fn-cache.h |
diffstat | 2 files changed, 32 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/fn-cache.cc Wed May 29 02:29:25 1996 +0000 +++ b/src/fn-cache.cc Fri May 31 04:43:11 1996 +0000 @@ -46,7 +46,7 @@ bool octave_fcn_file_name_cache::update (const string& path) { - bool retval = false; + bool something_changed = false; dir_path p = path.empty () ? dir_path (Vload_path) : dir_path (path); @@ -61,16 +61,16 @@ if (cache.contains (d)) { if (cache[d].update (d)) - retval = true; + something_changed = true; } else { cache[d] = file_name_cache_elt (d); - retval = true; + something_changed = true; } } - return retval; + return something_changed; } // Check to see if any of the elements in the cache need to be @@ -79,18 +79,30 @@ string_vector octave_fcn_file_name_cache::do_list (const string& path, bool no_suffix) { - // Only recompute the cache if something has changed. + update (path); - if (update (path)) - { - int total_len = 0; + string_vector fcn_file_names; + string_vector fcn_file_names_no_suffix; + + // For now, always generate the list of function files on each + // call. - dir_path p (Vload_path); + // XXX FIXME XXX -- this could probably be improved by keeping lists + // of all the function files for the current load path and only + // updating that when the load path changes. Have to be careful to + // return the right thing when we are only looking for a subset of + // all the files in the load path. + + int total_len = 0; - string_vector dirs = p.all_directories (); + dir_path p = path.empty () ? dir_path (Vload_path) : dir_path (path); + + string_vector dirs = p.all_directories (); - int ndirs = dirs.length (); + int ndirs = dirs.length (); + if (ndirs > 1) + { for (int i = 0; i < ndirs; i++) { string d = dirs[i]; @@ -123,6 +135,15 @@ } } } + else if (ndirs == 1) + { + string d = dirs[0]; + + file_name_cache_elt elt = cache[d]; + + fcn_file_names = elt.fcn_file_names; + fcn_file_names_no_suffix = elt.fcn_file_names_no_suffix; + } return no_suffix ? fcn_file_names_no_suffix : fcn_file_names; }
--- a/src/fn-cache.h Wed May 29 02:29:25 1996 +0000 +++ b/src/fn-cache.h Fri May 31 04:43:11 1996 +0000 @@ -112,13 +112,6 @@ // and the corresponding cache elements. CHMap<file_name_cache_elt> cache; - // The list of function file names in the cache. - string_vector fcn_file_names; - - // The list of function file names in the cache without the .m or - // .oct suffixes. - string_vector fcn_file_names_no_suffix; - string_vector do_list (const string& path, bool no_suffix); };