[vim/vim] Copying a List is slower than necessary (PR #21222)

2 views
Skip to first unread message

Julien Voisin

unread,
Sep 4, 2026, 4:24:41 PM (yesterday) Sep 4
to vim/vim, Subscribed

Problem: Copying or slicing a List allocates every item individually,
even though the number of items is known in advance.
Solution: Allocate the List and all of its items in a single block with
list_alloc_with_items(), as list_concat() already does.

Measured with perf stat -e instructions on workloads that model list-heavy plugin usage:

  • windowed slicing over a 120k-item list (pager/fuzzy-finder): -10.7%
  • copy() of an 800-item list, repeated (state snapshotting): -39.2%
  • deepcopy() of a nested list structure (config cloning): -42.6%

As a nice side-effect, I think it makes the code a tad more clear/clean.


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

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

Commit Summary

  • 42c99cd Copying a List is slower than necessary

File Changes

(1 file)

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/21222@github.com>

Reply all
Reply to author
Forward
0 new messages