Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH 1/2] __git_recent_branches: Retrieve less data, but faster.
- X-seq: zsh-workers 40817
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH 1/2] __git_recent_branches: Retrieve less data, but faster.
- Date: Fri, 10 Mar 2017 09:05:16 +0000
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=006 nH/UVf0H7hDMJptXHwhZxAYg=; b=Kb0AzLU0KSfcvQ2g1KjslCjL62nN1pFdTXT 95omfSZbzbbbeotDMYxayeNGSWphUvAcBK2tp36QC0VojjfiqNtXmxkzVCznDz67 0UaXI1zef9/E4Z1vW2O/ysMD8aMHIWmCeQr8zAT8F39xYkOFaYBZDeMe76YA7vos HwJkFNhg=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=smtpout; bh=00 6nH/UVf0H7hDMJptXHwhZxAYg=; b=DY11HlpoWyAOtrueIJ/b7+eNSBkRHzXj/X AKZsjqQD4MuewaIbVqHBtDIpEXCap5nZrj9+iGVmOBJ+518J9nFR+w1bpQ0HuYEJ Wx1ISV0bVBPQP9qy7cozlacy8DkPRCRLAbeuCx+MuLe//Yq6bxtywKGR7ThGfuKl ei1224EiQ=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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] )) ||
Messages sorted by:
Reverse Date,
Date,
Thread,
Author