Uncouple the "impossible" branch of changed colors.
This improves startup speed and next-prompt speed by giving them flatter logic paths. At the cost of needing to maintain the basic idea in two places.
This commit is contained in:
+17
-13
@@ -36,25 +36,29 @@ set prompt_segment_kinds=( \
|
|||||||
prompt \
|
prompt \
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach kind ( ${prompt_segment_kinds} )
|
# The algorithm is duplicated with less branching to make startup a bit faster.
|
||||||
eval 'echo $?curr_'"${kind}"'_color' >& /dev/null
|
if ( ! $?cshenv_prompt_first_cache ) then
|
||||||
_debug "Eval of ${kind}"
|
foreach kind ( ${prompt_segment_kinds} )
|
||||||
if( $? == 0 ) then
|
eval 'set __new_this_color="${'"${kind}"'_color}"'
|
||||||
eval "set curr_${kind}_color=impossible"
|
|
||||||
endif
|
|
||||||
eval 'set __new_this_color="${'"${kind}"'_color}"'
|
|
||||||
eval 'set __curr_this_color="${curr_'"${kind}"'_color}"'
|
|
||||||
if( "${__new_this_color}" != ${__curr_this_color} ) then
|
|
||||||
eval 'set curr_'"${kind}"'_color="'${__new_this_color}'"'
|
eval 'set curr_'"${kind}"'_color="'${__new_this_color}'"'
|
||||||
set __this_color_seq="%{[`__build_sgr_code no-csi reset ${__new_this_color}`m%}"
|
set __this_color_seq="%{[`__build_sgr_code no-csi reset ${__new_this_color}`m%}"
|
||||||
eval 'set '"${kind}"'_color_seq="'"${__this_color_seq}"'"'
|
eval 'set '"${kind}"'_color_seq="'"${__this_color_seq}"'"'
|
||||||
endif
|
end
|
||||||
end
|
set cshenv_prompt_first_cache=1
|
||||||
|
else
|
||||||
|
foreach kind ( ${prompt_segment_kinds} )
|
||||||
|
eval 'set __new_this_color="${'"${kind}"'_color}"'
|
||||||
|
eval 'set __curr_this_color="${curr_'"${kind}"'_color}"'
|
||||||
|
if( "${__new_this_color}" == "${__curr_this_color}" ) continue
|
||||||
|
|
||||||
|
eval 'set curr_'"${kind}"'_color="'${__new_this_color}'"'
|
||||||
|
set __this_color_seq="%{[`__build_sgr_code no-csi reset ${__new_this_color}`m%}"
|
||||||
|
eval 'set '"${kind}"'_color_seq="'"${__this_color_seq}"'"'
|
||||||
|
end
|
||||||
|
endif
|
||||||
|
|
||||||
_debug "Done with color cacheing loop"
|
_debug "Done with color cacheing loop"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_debug "Dynamic color loading processed..."
|
_debug "Dynamic color loading processed..."
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user