Skip to content

perf(misc): make ensure_nil in-place instead of deep copy - #2243

Open
hood wants to merge 1 commit into
hrsh7th:mainfrom
hood:perf/ensure-nil-in-place
Open

hood wants to merge 1 commit into
hrsh7th:mainfrom
hood:perf/ensure-nil-in-place

Conversation

@hood

@hood hood commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Closes #2237

Summary

misc.ensure_nil now clears vim.NIL fields in place instead of deep-copying every item. Lists are still left untouched, and the existing spec passes unchanged.

Data

Time to build entries over 10 keystrokes. CPU time, best of 20. Benchmark in #2236.

Scenario Before After
6k items, full list 15.5 ms 10.3 ms (-33%)
6k items, isIncomplete 153.7 ms 113.6 ms (-26%)
20k items, isIncomplete 545.1 ms 378.6 ms (-31%)

Behaviour

Response items are now changed in place, which entry.fill_defaults already did. Setting an existing field to nil during pairs is allowed in Lua.

Testing

All 73 specs pass, luacheck reports 0 warnings, and touched files are formatted with stylua.

njhoffman added a commit to njhoffman/nvim-cmp that referenced this pull request Nov 6, 2026
Ports upstream PRs hrsh7th#2243 and hrsh7th#2244: ensure_nil works in place and skips data,
which it was altering by stripping vim.NIL values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: ensure_nil deep-copies every completion item

1 participant