[Top][All Lists]

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

Re: State of the overlay tree branch?

From: Eli Zaretskii
Subject: Re: State of the overlay tree branch?
Date: Wed, 21 Mar 2018 17:35:05 +0200

> From: Sebastien Chapuis <address@hidden>
> Cc: Sebastian Sturm <address@hidden>, address@hidden
> Date: Wed, 21 Mar 2018 15:14:18 +0100
> The language server protocol defines a position in file with zero-indexed
> line and column offsets [1]:
> ```
> interface Position {
>       line: number;
>       character: number;
> }
> ```
> lsp-mode uses heavily line-number-at-pos to convert an Emacs buffer
> point to a LSP position, and vice-versa [2].

line-number-at-pos is inefficient, in that it always counts from the
beginning of the buffer.  By keeping already computed line numbers
around, you could make a faster implementation if you count relative
line offsets using count-lines instead.

> This can happen thousands times on each keystroke.

_Thousands_ times for _each_ keystroke?  Why is that?  Most keystrokes
only change a single line, so how come you need thousands of lines
recounted each time?

> If Emacs could provide a function to do the conversion very fast (or at
> least faster than with line-number-at-pos), it would be great.

Given the above, I think you need to describe the issue in more
details, before we even begin designing the solution.

reply via email to

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