From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIMWL_WL_MED autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id bd81fb4b for ; Sun, 23 Dec 2018 11:57:14 +0000 (UTC) Received: (qmail 17625 invoked by alias); 23 Dec 2018 11:56:53 -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: 43930 Received: (qmail 2721 invoked by uid 1010); 23 Dec 2018 11:56:53 -0000 X-Qmail-Scanner-Diagnostics: from mail-it1-f174.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.100.2/25112. spamassassin: 3.4.2. Clear:RC:0(209.85.166.174):SA:0(-1.9/5.0):. Processed in 3.542589 secs); 23 Dec 2018 11:56:53 -0000 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=fHMJGmhfFpZPSlozuKhcWqqMa3TlBClWrVltXdiXOgg=; b=jth0XiczJj4zy+ckmT7TJwihR07H5RlPOO3GCavuIjwG6EZyQuXKNvGC5LJ3WaKj+x N+2xr387/DEO4neizLqIcqARY4VexGVTRRUuzG/BoeXHz268TJO04LP2wtjKzVMCvWNF +tUDcMAcGqh3VBftUeLcSMTVoUBkHL3JpLt3sulOyLBy9yFw22RxaTpEM6HQma1LHGpF CTtqC8YhBtd168leLdJWSO6g3SvND4dvF9nOAgr/0KQj2YqoSESqpbIVpYcQbXMsGvXK 4GwBH9Xuvn+bS+XWPvESAl85KLzYcmig6vRMHR35iGgKSk8z7PwVX0L2/z8YPfJSFkoK 9qGA== 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=fHMJGmhfFpZPSlozuKhcWqqMa3TlBClWrVltXdiXOgg=; b=ABDZiXgg3qdT+qXSwOCF2nNH7cumE3zGqNKy0zT9zVQsbdzfA0kt6bKra4k+Khne+f XREZI8wYiQ3TWZ7fZN/aYbcON/MGjlcYDPCDBhJdiB4B4jUp9S4dmTuuw4peK+3sUwy0 fPbF99aNRt3xEiR0/qhJkvppuCB8kZqWPg1iRWBYOHW5eAxYzsjUfxa577xl7BDN1P+X eYurBYYcg185+BbsUlBGY9bYDMUHnNCc2x7wpRS2QabOQ5O5Kor8GmGRNm589Bd6zB8n utb+CbVhWz0Ee0AB02pdY1cn+5hFK2eYZUwY4/gIIEAdt9cIIN0oft+T7HBJ5s7Dq7Us Zyhw== X-Gm-Message-State: AA+aEWYepNgDOkosYdKzxThPRmhKdRrbEuyfxDdDt2ic4ttLA9vyiji9 7hOurN9QRwDn8aUhgRcXczK+cHyg5dREzg== X-Google-Smtp-Source: ALg8bN77thoRI/lxVXaDqg564b4xu9LrI7a6l4neP5iVaFfSIXqN3mtCRAA++h7j6Lyx6vJEQgpREQ== X-Received: by 2002:a24:76d0:: with SMTP id z199mr6002349itb.165.1545566204801; Sun, 23 Dec 2018 03:56:44 -0800 (PST) From: dana Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.0 \(3445.100.39\)) Subject: [PATCH] _multi_parts: Improve match performance Message-Id: <5B40A4D4-49B5-4D46-8C7F-8FAA16AF90BE@dana.is> Date: Sun, 23 Dec 2018 05:56:43 -0600 To: Zsh workers X-Mailer: Apple Mail (2.3445.100.39) Re: workers/43914: The hanging loop i mentioned was actually introduced = in workers/28186. Before that it used an array filter with a pattern match, = but that had to be removed due to problems with special characters. Now that = we have the (b) flag, we can put it back. It's much faster. I also mentioned skipping the check entirely when there's no prefix or = suffix currently on the command line, and after testing various scenarios with = it i *think* that's OK to do. So i did that as well dana diff --git a/Completion/Base/Utility/_multi_parts = b/Completion/Base/Utility/_multi_parts index 3e2f36c9c..12ff965ed 100644 --- a/Completion/Base/Utility/_multi_parts +++ b/Completion/Base/Utility/_multi_parts @@ -127,8 +127,7 @@ while true; do return fi elif (( $#tmp1 )); then - local ret=3D1 tt - local -a mm + local ret=3D1 =20 # More than one match. First we get all strings that match the # rest from the line. @@ -145,11 +144,14 @@ while true; do SUFFIX=3D"$suf" fi =20 - for tt in $tmp1 - do - mm+=3D( "${(@M)matches:#$tt*}" ) - done - matches=3D( $mm ) + # The purpose of this check (or one purpose, anyway) seems to be = to ensure + # that the suffix for the current segment on the command line = doesn't + # match across segments. For example, we want $matches for = ac to + # include abc/d, but not abd/c. If we don't have anything on the = command + # line for this segment, though, we can skip it. (The difference = is only + # noticeable when there are a huge number of possibilities) + [[ -n $pre$suf ]] && + matches=3D( ${(@M)matches:#(${(j<|>)~${(@b)tmp1}})*} ) =20 if ! zstyle -t ":completion:${curcontext}:" expand suffix || [[ -n "$menu" || -z "$compstate[insert]" ]]; then