1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-05-21 15:36:04 +02:00
zsh/Misc
Suraj N. Kurapati d634a3d333 49128 (github #76): vcs_info-examples: optimize +vi-git-untracked()
Speed up the prompt on large and/or deep working directories by
stopping grep(1) as soon as it finds a single match, with `-q`.
Also, correct the regexp by adding a ^ anchor and increase its
specificity by accounting for the space in Porcelain Format v1.

Previously, +vi-git-untracked() waited for grep(1) to find all
matches of untracked files, redirecting them away to /dev/null,
before finally concluding that untracked files do indeed exist.

With this patch, I see 4x speedup on a large Git-enabled $HOME:

    $ time (git status --porcelain | wc -l)
    212
    0.01s user 0.02s system 0% cpu 9.021 total

    $ time (git status --porcelain | grep '??' &>/dev/null)
    0.01s user 0.02s system 0% cpu 12.294 total

    $ time (git status --porcelain | grep -q '^?? ' 2>/dev/null)
    0.01s user 0.01s system 0% cpu 3.097 total

Note that `-q` for grep(1) is in POSIX (IEEE Std 1003.1-2017):
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html

See discussion https://www.zsh.org/mla/workers/2021/msg01354.html
2021-07-06 01:56:07 +00:00
..
.distfiles 33047: use git to simplify massively source distribution file selection 2014-08-23 21:01:58 +01:00
bash2zshprompt 42826: remove link to now-spam website 2018-06-04 00:39:26 +02:00
c2z 45269: Fix misspellings in completions and elsewhere. 2020-01-09 13:42:02 +00:00
compctl-examples unposted: force latest version of files from vendor to main branch 2007-07-03 17:06:04 +00:00
globtests 24708: Misc/globtests, Src/pattern.c, Test/D02glob.ztst: 2008-03-30 22:14:22 +00:00
globtests.ksh unposted: force latest version of files from vendor to main branch 2007-07-03 17:06:04 +00:00
job-control-tests unposted: force latest version of files from vendor to main branch 2007-07-03 17:06:04 +00:00
lete2ctl unposted: force latest version of files from vendor to main branch 2007-07-03 17:06:04 +00:00
make-zsh-urls Remove RCS Id strings. 2000-05-16 16:22:14 +00:00
vcs_info-examples 49128 (github #76): vcs_info-examples: optimize +vi-git-untracked() 2021-07-06 01:56:07 +00:00