perf(vim.text): use lookup table implementation for hex encoding (#30080)

Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
Gregory Anders
2024-11-26 13:56:01 -06:00
committed by GitHub
parent e8450ef236
commit 99b5ffd688
3 changed files with 89 additions and 3 deletions

View File

@@ -26,5 +26,21 @@ describe('vim.text', function()
eq(output, vim.text.hexencode(input))
eq(input, vim.text.hexdecode(output))
end)
it('errors on invalid input', function()
-- Odd number of hex characters
do
local res, err = vim.text.hexdecode('ABC')
eq(nil, res)
eq('string must have an even number of hex characters', err)
end
-- Non-hexadecimal input
do
local res, err = vim.text.hexdecode('nothex')
eq(nil, res)
eq('string must contain only hex characters', err)
end
end)
end)
end)