From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29393 invoked by alias); 16 Jun 2018 02:56:21 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 43030 Received: (qmail 26257 invoked by uid 1010); 16 Jun 2018 02:56:21 -0000 X-Qmail-Scanner-Diagnostics: from mail-io0-f196.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.223.196):SA:0(-1.9/5.0):. Processed in 1.4566 secs); 16 Jun 2018 02:56:21 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_PASS,T_DKIMWL_WL_MED,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: dana@dana.is X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=ZyoNfSP2ZvfAEabSwJOZAW0aaZOpA62sjC6KZmiEhb8=; b=FC2ViThLpzeFUWZO6OY0DIS2p9GqpeQF9y6u3sZx4CUK4kYoOw7MqRkEztpU8s20kr SNb6JWj+jLMZ5aPOsDhbF6hhQdeDtMDq75Unjr0oeuo1ym9is6HhWNGuttI4CJZSCOqb 7SKeynlaY8QGnN2lW5gadAmRrUn7dRbsRXOBq8zhHyp42405IyO18r4GzGSxGhh4xVzm M2Bo3/Nl0xMHl673itx3kBGW+7KywIHnBGpwmW5VS1FUPdv5n57VaVk6WY+p0nrUFere 9mnD591IFOhc/W2j6gZ61H/n9+wncl6+HcFV3Q8xbU/I65P0y4WDz2ZD/9pqHJIVUHL+ k7rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:to; bh=ZyoNfSP2ZvfAEabSwJOZAW0aaZOpA62sjC6KZmiEhb8=; b=S6bkVJIYExdNcWt1fo6dCKAD0m11SYsCEpbQYWck2z2SXjcoD02GZlE4TSKA/ocwc/ j5sZWOYoZ9vjqfsSvbAbgV4rHAEhXfM2qbiji2ROcpp13VXNNLhH+eeEmUVFRRSRDlS+ 9iQE+brpPuyCJhTIk0My6DJbPmi1sX/5BA3iG2jG0rNm1nF9cfWW7HQu0vG95qKudJLi cM/FDrflc8htkvJkJWRdNlDQ/24LxdiLugBQHwH1av4dHCcBhUDdzVtBgzFa6pUyNkLd 6GeTEKpavrHcF5ci5v8sDjTyKyDTLjfgTOmPOtivWinRbXI0QKTU1les6+vG2GNCrFyU sK0g== X-Gm-Message-State: APt69E1++UduyOvpbiYa2hmQR051PHtG8lrGW/peDd7/6MKfy/3p+5Ub ZJFM829AoawSOu7+mtxUaceV/jAyfSg= X-Google-Smtp-Source: ADUXVKLRoX4NWL3Y7S1ZDv+5d9strRQlqazbiOZLHg/VpObXoq189sSYdER9CPAnb1zBg0bBpSXB4g== X-Received: by 2002:a6b:bd47:: with SMTP id n68-v6mr3725093iof.111.1529117776976; Fri, 15 Jun 2018 19:56:16 -0700 (PDT) From: dana Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [PATCH] VCS_Info: Replace VCS_Info_realpath() by :P Message-Id: <7CFD30F2-1205-492E-9226-45DF80BAE80E@dana.is> Date: Fri, 15 Jun 2018 21:56:15 -0500 To: Zsh workers X-Mailer: Apple Mail (2.3273) Some of the VCS stuff could stand to be modernised. Here's an easy one: = Remove VCS_Info_realpath() and replace it by the :P expansion modifier. This = reduces the time it takes VCS_INFO_bydir_detect() to walk up five directories on = my Mac from 40 ms (!) to 1 ms. The latter function is called at every single = prompt for each of the back-ends you have enabled (except git, luckily), so it can = add up. I thought about leaving the VCS_INFO_realpath() function itself, in case = someone has a custom back-end lying around that relies on it, but it's not part = of the public API (per the contrib documentation), so... too bad. (Plus, it's hard to imagine many people in the world running a more = obscure VCS than some of the stuff this ships with. I can't find a single result on = Google suggesting that anyone even knows about the cdv, mtn, svk, or tla = back-ends...) dana diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr = b/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr index e8c8e81de..705db65a7 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr @@ -81,7 +81,7 @@ else bzrbase=3D${bzr_info[branch_root]} ;; esac =20 - bzrbase=3D"$(VCS_INFO_realpath ${bzrbase})" + bzrbase=3D${bzrbase:P} =20 if [ -n "${bzr_info[checkout_of_branch]}" ] && \ zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "use-server" diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs = b/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs index ed738b98f..e9d172052 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs @@ -9,7 +9,7 @@ cvsbase=3D"." while [[ -d "${cvsbase}/../CVS" ]]; do cvsbase=3D"${cvsbase}/.." done -cvsbase=3D"$(VCS_INFO_realpath ${cvsbase})" +cvsbase=3D${cvsbase:P} cvsbranch=3D$(< ./CVS/Repository) rrn=3D${cvsbase:t} cvsbranch=3D${cvsbranch##${rrn}/} diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn = b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn index e1334f661..a773a727d 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn @@ -46,7 +46,7 @@ else done fi =20 -svnbase=3D"$(VCS_INFO_realpath ${svnbase})" +svnbase=3D${svnbase:P} =20 rrn=3D${svnbase:t} zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat = svnbranch || svnbranch=3D"%b:%r" diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_tla = b/Functions/VCS_Info/Backends/VCS_INFO_get_data_tla index f015e0cce..4e9cee8b9 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_tla +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_tla @@ -5,7 +5,7 @@ setopt localoptions extendedglob NO_shwordsplit local tlabase tlabranch =20 -tlabase=3D"$(VCS_INFO_realpath ${vcs_comm[basedir]})" +tlabase=3D${vcs_comm[basedir]:P} rrn=3D${tlabase:t} # tree-id gives us something like 'foo@example.com/demo--1.0--patch-4', = so: tlabranch=3D${${"$( ${vcs_comm[cmd]} tree-id )"}/*\//} diff --git a/Functions/VCS_Info/VCS_INFO_bydir_detect = b/Functions/VCS_Info/VCS_INFO_bydir_detect index 70b0fb6fa..b20c05c9c 100644 --- a/Functions/VCS_Info/VCS_INFO_bydir_detect +++ b/Functions/VCS_Info/VCS_INFO_bydir_detect @@ -4,11 +4,11 @@ =20 setopt localoptions NO_shwordsplit local dirname=3D$1 -local basedir=3D"." realbasedir file +local basedir=3D"." file =20 -realbasedir=3D"$(VCS_INFO_realpath ${basedir})" -while [[ ${realbasedir} !=3D '/' ]]; do - [[ -r ${realbasedir} ]] || return 1 +basedir=3D${basedir:P} +while [[ ${basedir} !=3D '/' ]]; do + [[ -r ${basedir} ]] || return 1 if [[ -n ${vcs_comm[detect_need_file]} ]] ; then [[ -d ${basedir}/${dirname} ]] && { for file in ${(s: :)${vcs_comm[detect_need_file]}}; do @@ -19,10 +19,9 @@ while [[ ${realbasedir} !=3D '/' ]]; do [[ -d ${basedir}/${dirname} ]] && break fi =20 - basedir=3D${basedir}/.. - realbasedir=3D"$(VCS_INFO_realpath ${basedir})" + basedir=3D${basedir:h} done =20 -[[ ${realbasedir} =3D=3D "/" ]] && return 1 -vcs_comm[basedir]=3D${realbasedir} +[[ ${basedir} =3D=3D "/" ]] && return 1 +vcs_comm[basedir]=3D${basedir} return 0 diff --git a/Functions/VCS_Info/VCS_INFO_realpath = b/Functions/VCS_Info/VCS_INFO_realpath deleted file mode 100644 index ce4a69402..000000000 --- a/Functions/VCS_Info/VCS_INFO_realpath +++ /dev/null @@ -1,7 +0,0 @@ -## vim:ft=3Dzsh -## Written by Frank Terbeck -## Distributed under the same BSD-ish license as zsh itself. - -setopt localoptions NO_shwordsplit chaselinks -# -q to avoid chpwd() invocations -( builtin cd -q $1 2>/dev/null && pwd; ) diff --git a/Functions/VCS_Info/vcs_info b/Functions/VCS_Info/vcs_info index 4e9ac6c6a..d67ae6bf5 100644 --- a/Functions/VCS_Info/vcs_info +++ b/Functions/VCS_Info/vcs_info @@ -26,7 +26,6 @@ static_functions=3D( VCS_INFO_nvcsformats VCS_INFO_patch2subject VCS_INFO_quilt - VCS_INFO_realpath VCS_INFO_reposub VCS_INFO_set =20