[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: `looking-back' strange warning
From: |
Tassilo Horn |
Subject: |
Re: `looking-back' strange warning |
Date: |
Fri, 02 Oct 2015 17:21:23 +0200 |
User-agent: |
Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux) |
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> `re-search-backward' already slow without LIMIT?
>
> Note that re-search-* performs a *search* whereas looking-at (and
> looking-back) perform a *match*, which is expected to be quicker.
>
> re-search-* is implemented by performing a *match* at every position
> and stop at the first where a match is encountered.
I see, so
(looking-back "foobar")
will call
(re-search-backward "\\(?:foobar\\)\\=")
which in turn will at best (if point is just right of a foobar
occurrence) move point backwards 6 times and perform a match each time.
In the worst case (if we're not right of a foobar occurrence) point
moves until (or LIMIT (point-min)) trying a match each time. So yes, I
now get that `looking-back' is slow especially when no LIMIT near is
given.
And the extension if GREEDY is t is pretty much the same as what
`re-search-*' does too (but of course in C), right? (But that
`looking-back' concats the regex each while iteration is needless
effort.)
Bye,
Tassilo
Re: `looking-back' strange warning, Andreas Röhler, 2015/10/08
Re: `looking-back' strange warning, Stefan Monnier, 2015/10/08
Re: `looking-back' strange warning,
Tassilo Horn <=
Re: `looking-back' strange warning, Artur Malabarba, 2015/10/08
Re: `looking-back' strange warning, Tassilo Horn, 2015/10/08