Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position.

From: Lars Ingebrigtsen <[email-masked]>
Date: Sun, 07 Feb 2021 20:34:56 +0100

Lars Ingebrigtsen <[email-masked]> writes:

> I'll try to whip up a benchmark with really long lines and see what
> happens.

(with-temp-buffer
  (dotimes (_ 10000)
    (insert (make-string (random 4000) ?a) "\n"))
  (benchmark-run 10
    (goto-char (point-min))
    (while (not (eobp))
      (line-number-at-pos (point))
      (forward-line 1))))

With this, the new version still wins...  but only slightly.  So the
cache does indeed help when we've got long lines (which was the point of
the cache, I guess?)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no