all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Arthur Miller <arthur.miller@live.com>
Cc: emacs-devel@gnu.org
Subject: Re: Which is faster: narrow-to-region or delete-region?
Date: Wed, 22 Sep 2021 08:51:04 +0300	[thread overview]
Message-ID: <83wnn9w43b.fsf@gnu.org> (raw)
In-Reply-To: <AM9PR09MB49771FFB125823ED820AF13596A19@AM9PR09MB4977.eurprd09.prod.outlook.com> (message from Arthur Miller on Tue, 21 Sep 2021 22:10:09 +0200)

> 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.  Moreover, it cannot trigger
GC, whereas delete-region method very well can.

> I have tried both and notice no differences.

Maybe in a very small buffer.



  reply	other threads:[~2021-09-22  5:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-21 20:10 Which is faster: narrow-to-region or delete-region? Arthur Miller
2021-09-22  5:51 ` Eli Zaretskii [this message]
2021-09-22  7:00   ` Arthur Miller
2021-09-22  7:41     ` Eli Zaretskii
2021-09-22  8:53       ` Arthur Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83wnn9w43b.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=arthur.miller@live.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.