emacs-devel
[Top][All Lists]
Advanced

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

Re: Which is faster: narrow-to-region or delete-region?


From: Arthur Miller
Subject: Re: Which is faster: narrow-to-region or delete-region?
Date: Wed, 22 Sep 2021 09:00:54 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Arthur Miller <arthur.miller@live.com>
>> Date: Tue, 21 Sep 2021 22:10:09 +0200
>> 
>> 
>> I have a DEFUN in the middle of a temporary buffer; which is faster to use to
>> eliminate the rest of the code from the calculations for font lock:
>> 
>> (narrow-to-region defun-begin defun-end)
>> 
>> or
>> 
>> (delete-region (point-min) defun-begin) +
>> (delete-region defun-end (point-max))
>
> The narrow-to-region method must be much faster, since it only sets a
> bunch of variables and does little else.

Thought so when saw the code, but wasn't sure.

> bunch of variables and does little else.  Moreover, it cannot trigger
> GC, whereas delete-region method very well can.

That too, wasn't even thinking about that. I am not so familiar how GC works
with code in C.

>> I have tried both and notice no differences.
>
> Maybe in a very small buffer.
I was just tested in help buffers with that patch I made. But it is interactive
so it is hard to see the difference; I haven't benchmarked.

Thank you. That was educative. And helpful.



reply via email to

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