[Top][All Lists]

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

Re: Long lines and bidi

From: Eli Zaretskii
Subject: Re: Long lines and bidi
Date: Mon, 11 Feb 2013 19:17:28 +0200

> Date: Sun, 10 Feb 2013 18:57:00 +0200
> From: Eli Zaretskii <address@hidden>
> Cc: address@hidden
> I just committed to the trunk revision 111724 with a couple of simple
> changes which speed up by a factor of 3 some redisplay operations,
> such as M-v or M->, in a buffer with very long lines.  Please try it.

Further measurements indicate that the bottleneck is in searches for
previous or next newline, or N-th previous/next newline.  These
searches are at the core of functions that compute pixel dimensions of
buffer text, when the display engine needs to figure out where to
start displaying the window after scrolling, or where to put point
after C-p or C-n.

As a typical example, a C-n in a buffer with truncate-lines set
non-nil requires us to find the next physical line in the buffer,
i.e. the next newline.  We currently do that by searching forward in
the buffer, one byte at a time, until we find a newline.  If lines are
very long, this is expensive.

When truncate-lines is nil, this problem doesn't exist for C-n, but a
similar problem exists for C-p: we need to find the _previous_
newline (which is many characters back when lines are long), and then
scan forward until we find a character that is displayed one screen
line above the one we were at when the user typed C-p.  Revision
111724 makes sure we don't go back more than one physical line, unless
really needed, but given the current design of the code, one full line
is the absolute minimum.

Turning on the newline cache speeds up these searches for a newline by
a factor of 2, which is not too spectacular, but not negligible.  Any
objections to turning on that caching by default in all buffers?

Beyond that, either we can find a much more efficient way of finding
the next or previous newline, or we will need a complete redesign and
re-implementation of the move_it_* family of functions, which is used
a lot by the display engine.

reply via email to

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