Directory caches.

This uses a rudimentary CPU speed check at launch to gate larger
cache sizes.  (This is on the theory that older systems or those
with weaker CPUs will struggle to walk the cache.)
This commit is contained in:
2026-07-30 03:36:45 -04:00
parent 9fa81dc171
commit 6788feba34
5 changed files with 77 additions and 22 deletions
+59 -21
View File
@@ -1,25 +1,63 @@
#if ( ! $?cshenv_gitdirs )
set cshenv_gitdirs=( /home/adam/cshenv:/home/adam/cshenv/.git )
_debug "chdir handler called"
if( ! $?cshenv_gitdirs ) then
set cshenv_gitdirs=()
endif
if( ! $?cshenv_nogitdirs ) then
set cshenv_nogitdirs=()
endif
if( ! $?cshenv_gitdir_cache_size ) set cshenv_gitdir_cache_size=32
set _masked_cwd=$cwd:as/ //
#echo "${_masked_cwd}"
set _search_key="${_masked_cwd}"
#echo "${_search_key}"
#echo "dirs $cshenv_gitdirs"
#echo "cache-match $cshenv_gitdirs:as/${_masked_cwd}//"
#echo "cache-match $cshenv_gitdirs:gx/^${_search_key}*/"
#set _cache_match = ( $cshenv_gitdirs:gx^${_search_key}* )
#if ( ${#_cache_match} == 1 ) then
#echo "Found ${_cache_match}"
#else
unset _git_dir_found
foreach dir ( ${cshenv_nogitdirs} )
_debug "Indir check: ${dir}"
set _dirname="${dir}"
if( "${_masked_cwd}" == "${_dirname}" ) then
_debug "In Table"
set _git_dir_found
unset _git_check
break
endif
end
foreach dir ( ${cshenv_gitdirs} )
if( $?_git_dir_found ) break
_debug "Indir check: ${dir}"
set _dirarray=(${dir:s// /} )
set _dirname="${_dirarray[1]}"
set _dirstore="${_dirarray[2]}"
if( "${_masked_cwd}" == "${_dirname}" ) then
_debug "In Table"
set _git_check="${_dirstore:as// /}"
break
endif
end
if( ! $?_git_dir_found ) then
set _git_check=( `git rev-parse --git-dir |&cat` )
#if ( -d "${_git_check}" ) then
#echo "Found and installed ${_git_check} git dir"
#set _masked_git=$_git_check:as/ //
#set cshenv_dirs=( ${cshenv_dirs} "${_masked_cwd}${masked_git}" )
#else
#echo "Found no git dir for ${_masked_cwd}"
#set cshenv_dirs=( ${cshenv_dirs} "${_masked_cwd}" )
#endif
#endif
if( $#_git_check == 1 ) then
set _load="${_git_check:as/ //}"
set cshenv_gitdirs=( ${cshenv_gitdirs} ${_masked_cwd}${_load} )
while( $#cshenv_gitdirs > ${cshenv_gitdir_cache_size} )
shift cshenv_gitdirs
end
else
unset _git_check
set cshenv_nogitdirs=( ${cshenv_nogitdirs} ${_masked_cwd} )
while( $#cshenv_nogitdirs > ${cshenv_gitdir_cache_size} )
shift cshenv_nogitdirs
end
endif
endif
_debug ${cshenv_gitdirs}
_debug ${cshenv_nogitdirs}