From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH 1/2] __git_recent_branches: Retrieve less data, but faster.
Date: Fri, 10 Mar 2017 09:05:16 +0000 [thread overview]
Message-ID: <1489136717-8280-1-git-send-email-danielsh@fujitsu.shahaf.local2> (raw)
By replacing the --grep-reflog=needle argument with a ${(M)...:#needle} filter,
we retrieve less data from the reflog, and consequently run (on my test cases)
16% to 40% faster. The trade-off is that we retrieve less data: instead of
retrieving the 1000 most recent 'checkout' operations, we retrieve the most
recent 1000 operations, which would include fewer than 1000 checkout operations.
Also change [[:xdigit:]] to [0-9a-f] since it's faster, however, the absolute
gain from this is minor compared to the cost of 'git reflog'.
---
Completion/Unix/Command/_git | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 43cbc46..73daedc 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -6126,12 +6126,13 @@ __git_recent_branches__names()
# 2. Extracts the move-source from each
# 3. Eliminates duplicates
# 4. Eliminates commit hashes (leaving only ref names)
+ # [This step is done again by the caller.]
#
# See workers/38592 for an equivalent long-hand implementation, and the rest
# of that thread for why this implementation was chosen instead.
#
# Note: since we obtain the "from" part of the reflog, we only obtain heads, not tags.
- reply=(${${(u)${${(0)"$(_call_program reflog git reflog -1000 -z --grep-reflog='\^checkout:\ moving\ from\ ' --pretty='%gs')"}#checkout: moving from }%% *}:#[[:xdigit:]](#c40)})
+ reply=(${${(u)${${(M)${(0)"$(_call_program reflog git reflog -1000 -z --pretty='%gs')"}:#(#s)checkout: moving from *}#checkout: moving from }%% *}:#[0-9a-f](#c40)})
}
(( $+functions[__git_recent_branches] )) ||
next reply other threads:[~2017-03-10 9:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-10 9:05 Daniel Shahaf [this message]
2017-03-10 9:05 ` [PATCH 2/2] _git-checkout: When completing local heads, prefer recently-checked-out ones. (after 38592) Daniel Shahaf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1489136717-8280-1-git-send-email-danielsh@fujitsu.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).