From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [BUG] Long line makes pattern matching (by //) hog Zsh
Date: Sun, 5 Jun 2016 21:47:23 +0200 [thread overview]
Message-ID: <CAKc7PVC+v4i0z1Q8DLw2MvQhx6a2BJ8A4QyDVJ+6m2YWN5h9fw@mail.gmail.com> (raw)
In-Reply-To: <160605121020.ZM7727@torch.brasslantern.com>
On 5 June 2016 at 21:10, Bart Schaefer <schaefer@brasslantern.com> 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
prev parent reply other threads:[~2016-06-05 19:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-05 14:36 Sebastian Gniazdowski
2016-06-05 19:10 ` Bart Schaefer
2016-06-05 19:37 ` Peter Stephenson
2016-06-05 20:39 ` Peter Stephenson
2016-06-05 21:21 ` Sebastian Gniazdowski
2016-06-06 0:07 ` Bart Schaefer
2016-06-05 19:47 ` Sebastian Gniazdowski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKc7PVC+v4i0z1Q8DLw2MvQhx6a2BJ8A4QyDVJ+6m2YWN5h9fw@mail.gmail.com \
--to=sgniazdowski@gmail.com \
--cc=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).