zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [BUG] Long line makes pattern matching (by //) hog Zsh
Date: Sun, 5 Jun 2016 12:10:20 -0700	[thread overview]
Message-ID: <160605121020.ZM7727@torch.brasslantern.com> (raw)
In-Reply-To: <CAKc7PVC=AES1LhY7tYTXrPsefX3CXgtUsxiVbDaxmc5o2iHnVw@mail.gmail.com>

On Jun 5,  4:36pm, Sebastian Gniazdowski wrote:
}
} 1. not backslash nor slash nor space [^ /\\\\]##
} 2. not number, slash, backslash, space [^0-9/\\\\ ]##
} 3. not slash, backslash [^/\\\\]#
} 4. end of line (#e)

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).


  reply	other threads:[~2016-06-05 19:10 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 [this message]
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

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=160605121020.ZM7727@torch.brasslantern.com \
    --to=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).