From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19508 invoked by alias); 11 Feb 2016 16:12:23 -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: X-Seq: 37949 Received: (qmail 29223 invoked from network); 11 Feb 2016 16:12: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,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=4ojpyUtwyAj7g2/+wMvn7ADOzOnW97pIp3teYQs+RpM=; b=hu3CCo3LMjxBNgyHcNFI+jKn/lQOHB9nAKhiKy6YLfr7vepaMKMtT3b1k29GVAUwla YXzqGYJ2f0nhSCBSRkNI41CHiQdSu86eYLOWwfXQtKmu0Ajl1bKFg0eHthgwvyCKsQSh 7BBBd4Q/1qf6f4S9+ml7w5HG9ZUKou04sL/xU/S+8VlHXJsvGne0W4Kgbpop/x9Vp4fo Fsi7+qgl//DZS5Igkp7y5eZtOFBrmc7EUom7Hy7Fe9qM85lopgdwfYI3A6V36FYxRRuF B1HJRjpvbc1G8J7V3mq+H941qCTL9cYlHR77GUoZJm2X9kBPraje7ynKsoWJ93Ainx++ U6ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=4ojpyUtwyAj7g2/+wMvn7ADOzOnW97pIp3teYQs+RpM=; b=UnKbRcmvi2ZZuxnsFGbiQEbKaAuNA3SJ6+KQWitd/zToaViW0dR30oqOLNZCbYARhZ BB647V0mztkYVf2ufSV4IZBzmOkuYE6IGAsccK6dpsIDEVI8gRUGXuTcpiiMTDQa975/ 2mrkNAx7LYB9Pd/poh1OLPKMfWDH1UKtCE+dD+jpXL325k0JWlo678R3as8c//uxoNXd DRigognDDNj7z37FbhhRQr9ivGwKaoHYVlKtTbLYV/E6OYP8m4HYHMKqxJQ3DvkXp8QS xHMlHnPIc7Z2NCxCNqazOr/ivRHSJajpurO1CNzR+wbfqjf2llW1aKmNcZiPsT/TzpZj g1Tw== X-Gm-Message-State: AG10YOT2DeoscrGJqT/8BqMTuNaKCl2De1nPH1GmRhjTC7pqwPLn+4kpScjpuwqL/j2R6eknTZJ83andK4Og0A== X-Received: by 10.25.142.201 with SMTP id q192mr4003838lfd.65.1455207137048; Thu, 11 Feb 2016 08:12:17 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <160111233259.ZM6719@torch.brasslantern.com> <160118223126.ZM28565@torch.brasslantern.com> <160119195608.ZM31931@torch.brasslantern.com> <20160123235303.GE20278@tarsus.local2> <160123222057.ZM16192@torch.brasslantern.com> <160210101846.ZM2333@torch.brasslantern.com> From: Sebastian Gniazdowski Date: Thu, 11 Feb 2016 17:11:57 +0100 Message-ID: Subject: Re: Slow highlighting (Re: "drop-in replacement" and transpose-words-match) To: Bart Schaefer Cc: Zsh hackers list Content-Type: text/plain; charset=UTF-8 On 11 February 2016 at 11:43, Sebastian Gniazdowski wrote: > That said, zsyh could be somewhat optimized if the ":howmany" syntax > would be utilized. Could came up with this: ./parse.zsh "zplugin.zsh" > out1.txt 128,78s user 8,61s system 99% cpu 2:17,85 total ./parse.zsh "zplugin.zsh" > out2.txt 74,34s user 8,38s system 99% cpu 1:23,12 total https://github.com/zsh-users/zsh-syntax-highlighting/pull/272 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -125,6 +125,7 @@ _zsh_highlight_main_highlighter() typeset -a ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW local -a options_to_set # used in callees local buf="$PREBUFFER$BUFFER" + integer len="${#buf}" region_highlight=() if (( path_dirs_was_set )); then @@ -234,11 +235,13 @@ _zsh_highlight_main_highlighter() # indistinguishable from 'echo foo echo bar' (one command with three # words for arguments). local needle=$'[;\n]' - integer offset=${${buf[start_pos+1,-1]}[(i)$needle]} + # Len-start_pos drops one character, but it should do it, as start_pos + # starts from next, not from "start_pos", character + integer offset=${${buf: start_pos: len-start_pos}[(i)$needle]} (( start_pos += offset - 1 )) (( end_pos = start_pos + $#arg )) else - ((start_pos+=${#buf[$start_pos+1,-1]}-${#${buf[$start_pos+1,-1]##([[:space:]]|\\[[:space:]])#}})) + ((start_pos+=(len-start_pos)-${#${${buf: start_pos: len-start_pos}##([[:space:]]|\\[[:space:]])#}})) ((end_pos=$start_pos+${#arg})) Best regards, Sebastian Gniazdowski