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: Marcin Borkowski
Subject: Re: looking-at-p slower than looking-at
Date: Wed, 25 Nov 2015 21:39:04 +0100
User-agent: mu4e 0.9.13; emacs 25.0.50.1

On 2015-11-25, at 16:48, Barry Margolin <barmar@alum.mit.edu> wrote:

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

Ah, I didn't think of that.  Stupid me.  (That might be the answer to
the question why my benchmarks were inconclusive.)

Thanks,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



reply via email to

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