help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: `looking-back' strange warning


From: Drew Adams
Subject: RE: `looking-back' strange warning
Date: Thu, 1 Oct 2015 22:13:01 -0700 (PDT)

> > You can pass (point-min) for the limit if that's what you want.
> > Making it optional Encourages people to think that looking-at is just
> > like looking-back, with the same performance characteristic, whereas
> > making it mandatory encourages people to put a reasonable limit and
> > hence avoid pathological behavior at the end of large buffers.
> 
> My two cents: Even if you specify an optimal limit, `looking-back' can
> still be unnecessarily slow.  For example,
>    (looking-back "xy" 2)
> is much slower than
>     (and (> (point) 2)
>          (save-excursion (goto-char (- (point) 2))
>                          (looking-at "xy")))
> where "xy" stands for any plain string.

Definitely.  And this is in fact a typical case of the
misuse: the string to check is often a literal, so its
length is known.

This is the first thing to mention about `looking-back',
in terms of performance: avoid it altogether, if you can.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]