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

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

Re: looking-at-p slower than looking-at


From: Barry Margolin
Subject: Re: looking-at-p slower than looking-at
Date: Wed, 25 Nov 2015 10:48:39 -0500
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

In article <mailman.675.1448463102.31583.help-gnu-emacs@gnu.org>,
 Nicolas Richard <nrichard@ulb.ac.be> wrote:

> Marcin Borkowski <mbork@mbork.pl> writes:
> 
> > You might also (depending on your use-case) want to use looking-at-p,
> > which is marginally slower than looking-at, but does not modify match
> > data.
> 
> Why is it slower and how much slower is it ? I don't see how it can
> happen from its implementation:
> 
> (defsubst looking-at-p (regexp)
>   "\
> Same as `looking-at' except this function does not change the match data."
>   (let ((inhibit-changing-match-data t))
>     (looking-at regexp)))
> 
> thanks,

It takes a tiny amount of time to bind the variable 
inhibit-changing-match-data. That's why it's a little slower.

On the other hand, it doesn't have to set the internal variables that 
hold the match data, so maybe they cancel out.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


reply via email to

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