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:
+59
-21
@@ -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}
|
||||
|
||||
+1
-1
@@ -207,7 +207,7 @@ endif
|
||||
set git_prompt=""
|
||||
set git_prefix=""
|
||||
set git_tracking_stat=""
|
||||
if( ${#_git_check} <= 1 ) then
|
||||
if( $?_git_check ) then
|
||||
set git_branch_text=( `cat ${_git_check}/HEAD` )
|
||||
set git_branch=${git_branch_text[2]:s.refs/heads/..}
|
||||
_debug "We see git branch |${git_branch}|"
|
||||
|
||||
@@ -13,6 +13,8 @@ _debug 'Initially detected that you are running on a "'${CSHENV_SYSTEM}'" system
|
||||
|
||||
_debug 'Detected that you are running on a "'${CSHENV_SYSTEM}'" system'
|
||||
|
||||
set cshenv_gitdir_cache_size=16
|
||||
|
||||
|
||||
# Source the common bits, since many systems often have lots in common.
|
||||
# For the moment, everything is in here.
|
||||
|
||||
@@ -2,6 +2,13 @@ _debug "Sourcing tcshrc.system.FreeBSD..."
|
||||
|
||||
set cshenv_sort_can_shuffle
|
||||
|
||||
set cshenv_speed_estimate=( `sysctl dev.cpu.0.freq` )
|
||||
set cshenv_speed_estimate="${cshenv_speed_estimate[2]}"
|
||||
|
||||
if( ${cshenv_speed_estimate} > 400 ) then
|
||||
set cshenv_gitdir_cache_size=256
|
||||
endif
|
||||
|
||||
# Set the acknowledgement bit, essentially
|
||||
setenv CSHENV_SYSTEM_CONFIGURED FreeBSD
|
||||
|
||||
|
||||
@@ -2,6 +2,14 @@ _debug "Sourcing tcshrc.system.Linux..."
|
||||
|
||||
set cshenv_sort_can_shuffle
|
||||
|
||||
set cshenv_speed_estimate=( `cat /proc/cpuinfo | grep bogomips | head -1` )
|
||||
set cshenv_speed_estimate=(${cshenv_speed_estimate:as/./ /})
|
||||
set cshenv_speed_estimate="${cshenv_speed_estimate[3]}"
|
||||
|
||||
if( ${cshenv_speed_estimate} > 800 ) then
|
||||
set cshenv_gitdir_cache_size=256
|
||||
endif
|
||||
|
||||
unset cshenv_battery_device
|
||||
unset cshenv_show_battery_level
|
||||
|
||||
|
||||
Reference in New Issue
Block a user