From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6194 invoked by alias); 10 Feb 2016 18:37:25 -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: 37941 Received: (qmail 28182 invoked from network); 10 Feb 2016 18:37:23 -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=BMeBcIRMHkiMpPm1iG5EhIN7Y6/Z7nYECiS9Y6M6mTk=; b=c4rm+lYxlwWW+3wwvAQ8poV5ZlcM4i1YGxm+5fuz+MdngV5H5seCNuQ4tOBpR1pFHY MQj50sUxBKgJC/oPZ7klUjGQ76TnDkjDArbFCIvH5/6N8Dr80dQ55RRg+l2q84gYbAaT WfY76vjtF5CGcSmn+wmhfetxoLCRr1Ow9FEz/etEziusjkv5v3al9R4ehZf6pwpbJmoQ zN3vwWge/ZIUdI+VLXsdDS3bLAjLJsQFJ1ypl0+kfzNJdnjGwXIlxe3RwNYaZwYJf+n8 udicvzVBq4OxvkW23q/bfKyv6qa3OB5ZQjhl8OU3g8/P5+wP1FhZ7B1PCCk8k/30kJ4V PL5g== 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=BMeBcIRMHkiMpPm1iG5EhIN7Y6/Z7nYECiS9Y6M6mTk=; b=B8t5gdTFv7A9VZpum5/cw6Q0KUqL/2aBYLTHSmR4V1UntyD0JgDMp1ya+UaYIX5M58 ZLeQYkkFFrIctEw8FhTC+MkV1ea/v2TxkeHNRBJnovPr0pO/Ow3s7QpcL8eFcE9fwR1a NtGHgTBSEeB3Ij4WuXoxdL6+0h4MEYGFLIk4RCKIkkBCFPdnCfYIGhZImuoXndkakCYj +giGmxRL8XdM1hYW86ZBM87+eyVFKTemSg8xikAnCyNQZoZpSq0VyND7w2uFuzZbVe4L 0OnxQF4dIDUBFdrrVUJhkD02stDruUQrh+kZxJgEsVb9oupYC4YY5WcZM0whtgWpZXGC QQSg== X-Gm-Message-State: AG10YOQLia4qTws96m74QGI5h5GEnT/mmxPpFAH0tUUnYYV2AToGAMrd6jLAZG7MtCwQsoCkoDCFiJmHdOaN8w== X-Received: by 10.25.44.213 with SMTP id s204mr7653034lfs.148.1455129440815; Wed, 10 Feb 2016 10:37:20 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <160210101846.ZM2333@torch.brasslantern.com> 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: Wed, 10 Feb 2016 19:37:01 +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 Did a following test and indeed zed on 323 lines long function is still slow --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -87,10 +87,10 @@ _zsh_highlight_main_add_region_highlight() { # NOTE: This runs 'setopt', but that should be safe since it'll only ever be # called inside a $(...) subshell, so the effects will be local. _zsh_highlight_main__type() { - if (( $#options_to_set )); then - setopt $options_to_set; - fi - LC_ALL=C builtin type -w -- $1 2>/dev/null + typeset -a arr + arr=( ': reserved' ': suffix alias' ': alias' ': builtin' ': function' ': command' ': hashed' ) + integer len=${#arr} + REPLY=${arr[ (RANDOM % len) + 1 ]} } # Main syntax highlighting function. @@ -283,7 +283,8 @@ _zsh_highlight_main_highlighter() else _zsh_highlight_main_highlighter_expand_path $arg local expanded_arg="$REPLY" - local res="$(_zsh_highlight_main__type ${expanded_arg})" + _zsh_highlight_main__type ${expanded_arg} + local res="$REPLY" () { # Special-case: command word is '$foo', like that, without braces or anything. # @@ -295,7 +296,8 @@ _zsh_highlight_main_highlighter() local MATCH; integer MBEGIN MEND if [[ $res == *': none' ]] && (( ${+parameters} )) && [[ ${arg[1]} == \$ ]] && [[ ${arg:1} =~ ^([A-Za-z_][A-Za-z0-9_]*|[0-9]+)$ ]]; then - res="$(_zsh_highlight_main__type ${(P)MATCH})" + _zsh_highlight_main__type ${(P)MATCH} + res="$REPLY" fi } Best regards, Sebastian Gniazdowski