Skip to content

Commit

Permalink
Cache base64 alphabet (#634)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasfaingnaert authored Dec 27, 2019
1 parent ae1aa14 commit 094a49d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions autoload/lsp/utils.vim
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,9 @@ function! s:get_base64_alphabet() abort
return l:alphabet
endfunction

let s:alphabet = s:get_base64_alphabet()

function! lsp#utils#base64_decode(data) abort
let l:alphabet = s:get_base64_alphabet()
let l:ret = []

" Process base64 string in chunks of 4 chars
Expand All @@ -256,7 +257,7 @@ function! lsp#utils#base64_decode(data) abort
" Convert 4 chars to 3 octets
for l:char in split(l:group, '\zs')
let l:group_dec = l:group_dec * 64
let l:group_dec += max([index(l:alphabet, l:char), 0])
let l:group_dec += max([index(s:alphabet, l:char), 0])
endfor

" Split the number representing the 3 octets into the individual
Expand Down

0 comments on commit 094a49d

Please sign in to comment.