diff options
| author | João Távora | 2026-01-09 15:45:08 +0000 |
|---|---|---|
| committer | João Távora | 2026-01-11 03:42:01 +0000 |
| commit | 236647ab58e6d3dd0b092e753c54317ad9004f39 (patch) | |
| tree | 8be4bbb7855e7dba090adf88501dc2631c874b65 /java/incrementing-version-code | |
| parent | fa5a65629262d47d95c70e5e1404b225ce7fb2f8 (diff) | |
| download | emacs-236647ab58e6d3dd0b092e753c54317ad9004f39.tar.gz emacs-236647ab58e6d3dd0b092e753c54317ad9004f39.zip | |
Eglot: spectacular optimization in files with many diagnostics
In a large (or simply long) file with many diagnostics, calling
eglot-range-region repeteadly constantly throws Emacs for a spin
around the buffer, since each diagnostics comes annotated with a
(line/col): LSP range spec that is reasonably expensive to
translate into Elisp point positions.
A much faster approach for such large lists is to first sort all the
objects containing ranges by their start lines and then do a
single pass of the buffer, moving lines by delta.
By much faster, I do mean spectacularly (100x) faster. A long python
with 7000 "ruff" diagnostics, before the change, typical editor
operations (add/delete words) are impossible.
14053 84% - jsonrpc-connection-receive
14052 84% - #<byte-code-function B94>
14052 84% - apply
14052 84% - eglot-handle-notification
14052 84% - applyn
14052 84% - #<byte-code-function 6DB>
14052 84% - eglot--flymake-handle-push
12295 74% - eglot--flymake-make-diag
12218 73% + eglot-range-region
50 0% + eglot--check-object
12 0% plist-member
3 0% flymake-make-diagnostic
After the change:
99 1% - jsonrpc-connection-receive
99 1% - #<byte-code-function 0EE>
99 1% - apply
99 1% - eglot-handle-notification
99 1% - apply
99 1% - #<byte-code-function E84>
99 1% - eglot--flymake-handle-push
99 1% - eglot--call-with-ranged
99 1% - #<byte-code-function 2C6>
99 1% - eglot-move-to-utf-16-linepos
99 1% line-end-position
* lisp/progmodes/eglot.el (eglot-move-to-linepos-function):
Forward declare.
(eglot--call-with-ranged, eglot--collecting-ranged): New helpers.
(eglot--flymake-report-1)
(eglot--imenu-SymbolInformation): Use eglot--collecting-ranged.
(eglot--imenu-DocumentSymbol): Could use eglot--collecting-ranged.
* etc/EGLOT-NEWS: Mention it
Diffstat (limited to 'java/incrementing-version-code')
0 files changed, 0 insertions, 0 deletions