emacs-devel
[Top][All Lists]
Advanced

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

Re: Searching for line beginning


From: Lars Ingebrigtsen
Subject: Re: Searching for line beginning
Date: Mon, 15 Aug 2022 06:28:05 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

By the way, I see that Fline_beginning_position/end have grown field
capabilities while I wasn't looking (in 2000).  I.e., they call
Fconstrain_to_field, which is a pretty complex function.  This means
that rewriting a loop like

  (let ((sum 0))
    (goto-char (point-min))
    (while (not (eobp))
      (goto-char (line-end-position))
      (setq sum (+ sum (point)))
      (forward-char 1))
    sum)

into

  (let ((sum 0))
    (goto-char (point-min))
    (while (not (eobp))
      (forward-line 1)
      (setq sum (+ sum (1- (point)))))
    sum)

is more than twice as fast, which is sad.  (Because `forward-line'
doesn't do the field stuff.)

The field stuff only makes sense in user-oriented buffers, while we use
line-end-position extensively in Emacs to parse buffers in general --
but we get this field penalty throughout Emacs.




reply via email to

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