[vim/vim] Dictionary items() allocates pair elements separately (PR #21384)

6 views
Skip to first unread message

mattn

unread,
Sep 27, 2026, 7:49:39 PM (9 days ago) Sep 27
to vim/vim, Subscribed

Dictionary items() currently allocates each [key, value] list and its two items separately. Allocate the pair together using list_alloc_with_items(2), reducing three allocations to one per pair while preserving value references. Add a regression test covering pair mutation and shared values after the source dictionary is freed.

Before/after measurements for repeated items() calls on dictionaries with decimal string keys and Number values (median of five runs, GCC -O2; baseline 1b405bb705, patched 26ac0a447b):

Dictionary entries Calls per run Before After Time reduction
4,096 4,882 2.603719 s 1.557332 s 40.2%
65,536 305 3.323465 s 1.876700 s 43.5%

Dictionary setup is excluded from timing; replacing and freeing the previous result is included. These are focused microbenchmarks, not editor-wide speedups, and runs were not CPU-pinned.

Validation: make -C src -j4 completed without compiler warnings, all 59 tests in test_listdict.vim passed, and git diff --check passed.


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

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

Commit Summary

  • 26ac0a4 patch 9.2.NNNN: dictionary items() allocates pair elements separately

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

Christian Brabandt

unread,
Sep 28, 2026, 3:02:14 PM (8 days ago) Sep 28
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#21384)

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

Reply all
Reply to author
Forward
0 new messages