From bf16b14f46b9698becd46bb4e1751319219358b7 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 8 Jun 2019 14:18:35 +0200 Subject: [PATCH] vim-patch.sh: improve performance #10137 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `vim-patch.sh -L`: down to ~0.5s from ~85s. `vim-patch.sh -l`: down to ~6s from ~90s. % diff old new: 193c193 < • v8.0.1366 --- > • v8.0.1367 354d353 < • v8.0.1738 This is due to duplicate tags for Vim commits (https://github.com/vim/vim/issues/4510): - vim/vim@1ad022a9b: tagged as v8.0.1367, v8.0.1366 - vim/vim@5d69da462: tagged as v8.0.1739, v8.0.1738 --- scripts/vim-patch.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 286aaaea9e..6f71f15ddf 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -382,12 +382,21 @@ list_vimpatch_numbers() { list_missing_vimpatches() { local token vim_commit vim_tag patch_number declare -A tokens + declare -A vim_commit_tags # Find all "vim-patch:xxx" tokens in the Nvim git log. for token in $(list_vimpatch_tokens); do tokens[$token]=1 done + # Create an associative array mapping Vim commits to tags. + eval "declare -A vim_commit_tags=( + $(git -C "${VIM_SOURCE_DIR}" for-each-ref refs/tags \ + --format '[%(objectname)]=%(refname:lstrip=2)' \ + --sort='-*authordate' \ + --shell) + )" + # Get missing Vim commits for vim_commit in $(list_vim_commits); do # Check for vim-patch: (usually runtime updates). @@ -396,7 +405,8 @@ list_missing_vimpatches() { continue fi - if vim_tag="$(git -C "${VIM_SOURCE_DIR}" describe --tags --exact-match "${vim_commit}" 2>/dev/null)"; then + vim_tag="${vim_commit_tags[$vim_commit]-}" + if [[ -n "$vim_tag" ]]; then # Check for vim-patch: (not commit hash). patch_number="vim-patch:${vim_tag:1}" # "v7.4.0001" => "7.4.0001" if [[ "${tokens[$patch_number]-}" ]]; then