Subject: bug#27427: 26.0.50; Native line numbers lead to display error in company-mode popup

From: Eli Zaretskii <[email-masked]>
Date: Sun, 25 Jun 2017 22:00:30 +0300

> Date: Sun, 25 Jun 2017 17:59:01 +0200
> From: martin rudalics <[email-masked]>
> CC: [email-masked], [email-masked]
> 
> I also voted for a line numbers cache like that of (or even in
> combination with) the 'syntax-ppss' cache but that's a different
> subject.

For the record, IME caches are problematic in the display code.
Various display routines are invoked from semi-random places,
sometimes utterly unrelated to display per se.  As a typical example,
consider vertical-motion.

Also, redisplay optimizations many time perform layout only for small
portions of the window/frame, so you cannot easily rely on the fact
that you will be called for a significant number of screen lines,
something which would favor caching.

Last, but definitely not least, caching gets in the way when the
display engine decides it should abandon some layout attempt, back up,
and continue from some previous state of the layout process.  Many
times, this requires to reset the cache as well, which complicates
management.

So my advice is always to try to code efficient algorithms that can
perform reasonably fast without caching.  It turned out that counting
line (using the same code we always used for line-number display in
the mode line) is just such a fast method.