[vim/vim] placing many signs is slower than necessary (PR #21237)

8 views
Skip to first unread message

Julien Voisin

unread,
Sep 6, 2026, 7:53:12 AM (3 days ago) Sep 6
to vim/vim, Subscribed

Problem: Placing many signs, for example with sign_placelist(), is
slower than necessary because buf_addsign() rescans the
buffer's sign list from its head for every sign to find the
insertion point, which is quadratic in the number of signs.
Solution: Remember the last inserted sign and resume the search from it
when the next sign is on a later line (Julien Voisin).

buf_addsign() inserts signs in line-number order, so when signs are placed on distinct, ascending lines (the common case for sign_placelist() and for plugins that place many signs) resuming each search from the previously inserted sign instead of the head makes the total work linear rather than quadratic. Signs placed on the same line still fall back to a scan from the head.

Placing 16000 signs with explicit ids in ascending order drops from about a quarter of a second to a few milliseconds.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/21237

Commit Summary

  • 823bf01 placing many signs is slower than necessary

File Changes

(2 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/21237@github.com>

Christian Brabandt

unread,
Sep 7, 2026, 4:21:45 PM (2 days ago) Sep 7
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#21237)

thanks


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/21237/c5575300475@github.com>

Reply all
Reply to author
Forward
0 new messages