From 3b543a4ecc7154cbe62d43445a5bfaada8418563 Mon Sep 17 00:00:00 2001 From: Sebastian Gniazdowski Date: Sun, 16 Oct 2016 15:17:13 +0200 Subject: [PATCH] *highlight: Coloring history doesn't need checking a path as prefix parse.zsh -oo, before change: Running time: 2.3793230000 num calls time self name ----------------------------------------------------------------------------------- 1) 350 2371,62 6,78 100,00% 1636,82 4,68 69,02% -hsmw-highlight-process 2) 2800 365,84 0,13 15,43% 365,84 0,13 15,43% -hsmw-highlight-string 3) 2450 195,43 0,08 8,24% 135,32 0,06 5,71% -hsmw-highlight-check-path 4) 3850 92,77 0,02 3,91% 92,77 0,02 3,91% -hsmw-highlight-expand-path 5) 1400 67,54 0,05 2,85% 67,54 0,05 2,85% (anon) 6) 1400 43,99 0,03 1,85% 43,99 0,03 1,85% -hsmw-highlight-main-type 7) 700 11,19 0,02 0,47% 11,19 0,02 0,47% -hsmw-highlight-check-assign 8) 350 9,66 0,03 0,41% 9,66 0,03 0,41% -hsmw-highlight-stack-pop parse.zsh -oo, after change: Running time: 2.3625050000 num calls time self name ----------------------------------------------------------------------------------- 1) 350 2354,85 6,73 100,00% 1649,87 4,71 70,06% -hsmw-highlight-process 2) 2800 366,95 0,13 15,58% 366,95 0,13 15,58% -hsmw-highlight-string 3) 2450 163,48 0,07 6,94% 103,18 0,04 4,38% -hsmw-highlight-check-path 4) 3850 92,94 0,02 3,95% 92,94 0,02 3,95% -hsmw-highlight-expand-path 5) 1400 68,50 0,05 2,91% 68,50 0,05 2,91% (anon) 6) 1400 43,79 0,03 1,86% 43,79 0,03 1,86% -hsmw-highlight-main-type 7) 700 11,32 0,02 0,48% 11,32 0,02 0,48% -hsmw-highlight-check-assign 8) 350 9,65 0,03 0,41% 9,65 0,03 0,41% -hsmw-highlight-stack-pop Main execution time is quite unstable, but *-check-path() running time is ok. 30ms gain. --- hsmw-highlight | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/hsmw-highlight b/hsmw-highlight index 6e103f4..7f4ab1b 100644 --- a/hsmw-highlight +++ b/hsmw-highlight @@ -661,16 +661,6 @@ typeset -gA HSMW_HIGHLIGHT_STYLES [[ -e "$cdpath_dir/$expanded_path" ]] && return 0 done - # If dirname($arg) doesn't exist, neither does $arg. - [[ ! -d ${expanded_path:h} ]] && return 1 - - # If this word ends the buffer, check if it's the prefix of a valid path. - if [[ ${buf[1]} != "-" && $pure_buf_len == $end_pos ]]; then - local -a tmp - tmp=( ${expanded_path}*(N) ) - (( $#tmp > 0 )) && REPLY=path_prefix && return 0 - fi - # It's not a path. return 1 }