Subject: Re: bug#35675: 27.0.50; Is line-number-at-pos unnecessarily slow?

From: "Basil L. Contovounesios" <[email-masked]>
Date: Sat, 11 May 2019 21:36:59 +0100

Alex Branham <[email-masked]> writes:

> line-number-at-pos basically regex searches forward for \n's and
> counts them up.

It only does this (via count-lines) if selective-display is t, which is
deprecated and seldom used.  Otherwise it uses the value returned by
forward-line (defined in C), which calls find_newline, which AFAIK uses
the buffer's newline cache to some extent (I'm not familiar with its
implementation).

Either way, as Eli says, there's often an algorithmic solution to
slowness in uses of count-lines.

Thanks,

-- 
Basil