Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [BUG] Long line makes pattern matching (by //) hog Zsh
- X-seq: zsh-workers 38618
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: [BUG] Long line makes pattern matching (by //) hog Zsh
- Date: Sun, 5 Jun 2016 21:47:23 +0200
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- 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-transfer-encoding; bh=zFqSxO/cLkJ5ohFusUONSgmUZwnlspZuK+UQEmCpabs=; b=amXV0Xbk1EgxY0E/ugA90/KrTfq+gpo49sVixg+D4dsI/wxjkIR6htd+uRywVv2NoR XWMVPdN4TAHdTLZj1dYjs72PfFsKzrBTeIqZCiCLKx3Xs1mLHDxKrmNFVSxQ+V74BmwI qUMaWvbI8RfCp5g0mdIez0/yUb/A9T64pp0ilaRpR8BpMCm9Vkjt3hf6XXHXMs1Qq7rL vo6O11svgAlYyNHq3PbzfXWoFj9jBLSrZlYlP3A53nzTRcxXIYPnxsdWWUEHPOnWEjOB 88xQLT76iyfpz4VCtHONtkkUI60FTIdHcVpX5o0z8FwQ828YFuI8HYdyzJeGZHzvAics ugVg==
- In-reply-to: <160605121020.ZM7727@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVC=AES1LhY7tYTXrPsefX3CXgtUsxiVbDaxmc5o2iHnVw@mail.gmail.com> <160605121020.ZM7727@torch.brasslantern.com>
On 5 June 2016 at 21:10, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> It's in the block in pattern.c:patchmatch() that begins with the
> comment:
>
> /*
> * Lookahead to avoid useless matches. This is not possible
> * with approximation.
> */
>
> Specifically, in the "if (no >= min) for (;;) ..." loop, at each charater
> in the input string patmatch() is called recursively to look at the rest
> of the string, which again enters this same loop because the next thing
> is also a one-or-more expression, which calls recursively and again
> enters the loop because the thing after that is a zero-or-more.
>
> It consumes a LOT of memory while doing this, even if I add a hack to
> prevent it from recursively re-entering lookahead (or to skip the
> lookahead entirely).
Too bad the input isn't even that large, ~2850 characters. And that
the pattern even with first segment removed – ([^0-9/\\\\
]##[^/\\\\]#(#e)) – i.e. two 0/1-or-more segments, is also slow,
although doesn't hog Zsh. Maybe your changes would make a difference
for that input size, and for first segment removed, i.e. two # or ##
blocks? I had simplified highlighting in my tool and should be fine
now, but maybe in future I could restore the more sophisticated
pattern.
Best regards,
Sebastian Gniazdowski
Messages sorted by:
Reverse Date,
Date,
Thread,
Author