mirror of
https://github.com/neovim/neovim
synced 2025-07-16 09:11:51 +00:00
feat(lua): add noref to deepcopy
Problem: Currently `deepcopy` hashes every single tables it copies so it can be reused. For tables of mostly unique items that are non recursive, this hashing is unnecessarily expensive Solution: Port the `noref` argument from Vimscripts `deepcopy()`. The below benchmark demonstrates the results for two extreme cases of tables of different sizes. One table that uses the same table lots of times and one with all unique tables. | test | `noref=false` (ms) | `noref=true` (ms) | | -------------------- | ------------------ | ----------------- | | unique tables (50) | 6.59 | 2.62 | | shared tables (50) | 3.24 | 6.40 | | unique tables (2000) | 23381.48 | 2884.53 | | shared tables (2000) | 3505.54 | 14038.80 | The results are basically the inverse of each other where `noref` is much more performance on tables with unique fields, and `not noref` is more performant on tables that reuse fields.
This commit is contained in:
committed by
Lewis Russell
parent
a064ed6229
commit
3734519e3b
@ -1353,7 +1353,7 @@ function lsp.start_client(config)
|
||||
---@param context? {bufnr: integer}
|
||||
---@param handler? lsp.Handler only called if a server command
|
||||
function client._exec_cmd(command, context, handler)
|
||||
context = vim.deepcopy(context or {}) --[[@as lsp.HandlerContext]]
|
||||
context = vim.deepcopy(context or {}, true) --[[@as lsp.HandlerContext]]
|
||||
context.bufnr = context.bufnr or api.nvim_get_current_buf()
|
||||
context.client_id = client.id
|
||||
local cmdname = command.command
|
||||
|
Reference in New Issue
Block a user