From c5af5c0b9ab84c86f84e32210512923e7eb641ba Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Tue, 23 Apr 2024 18:23:45 +0300 Subject: 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 }`. --- test/functional/lua/vim_spec.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'test/functional/lua/vim_spec.lua') diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index 3b47d7a667..bb8b43caf7 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -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([[ -- cgit