perf(lua): faster vim.deprecate() #28470

Problem: `vim.deprecate()` can be relatively significantly slower than
  the deprecated function in "Nvim" plugin.
Solution: Optimize checks for "Nvim" plugin. This also results into not
  distinguishing "xxx-dev" and "xxx" versions when doing checks, which
  is essentially covered by the deprecation logic itself.

With this rewrite I get the times from #28459: `{ 0.024827, 0.003797, 0.002024, 0.001774, 0.001703 }`.
For quicker reference:
    -  On current Nightly it is something like `{ 3.72243, 0.918169, 0.968143, 0.763256, 0.783424 }`.
    - On 0.9.5: `{ 0.002955, 0.000361, 0.000281, 0.000251, 0.00019 }`.
This commit is contained in:
Evgeni Chasnovski
2024-04-23 18:23:45 +03:00
committed by GitHub
parent a4fc3bb0e6
commit c5af5c0b9a
2 changed files with 19 additions and 28 deletions

View File

@@ -147,8 +147,10 @@ describe('lua stdlib', function()
end)
it('when plugin = nil', function()
local cur = vim.version.parse(current_version)
local cur_to_compare = cur.major .. '.' .. cur.minor
local was_removed = (
vim.version.ge(current_version, '0.10') and 'was removed' or 'will be removed'
vim.version.ge(cur_to_compare, '0.10') and 'was removed' or 'will be removed'
)
eq(
dedent([[