diff options
| author | TJ DeVries <devries.timothyj@gmail.com> | 2020-09-15 14:15:55 -0400 |
|---|---|---|
| committer | TJ DeVries <devries.timothyj@gmail.com> | 2020-09-15 14:15:55 -0400 |
| commit | 6ffa3c24b3b46d3ce789bae799b17d1a369dec3f (patch) | |
| tree | 6784a40d72a5c8de781929d2ec8f9bccaba3ece7 /lua/telescope | |
| parent | 0ab858d9fedf962abca2237c6de1344780e46b45 (diff) | |
feat: improve (?) performance of default sorter
Diffstat (limited to 'lua/telescope')
| -rw-r--r-- | lua/telescope/sorters.lua | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lua/telescope/sorters.lua b/lua/telescope/sorters.lua index 9e17cf2..dd7cf4f 100644 --- a/lua/telescope/sorters.lua +++ b/lua/telescope/sorters.lua @@ -77,26 +77,28 @@ sorters.get_fuzzy_file = function(opts) opts = opts or {} local ngram_len = opts.ngram_len or 2 - local os_sep = '/' + local os_sep = util.get_separator() + local match_string = '[^' .. os_sep .. ']*$' local cached_tails = setmetatable({}, { __index = function(t, k) - local tail_split = vim.split(k, os_sep) - local tail = tail_split[#tail_split] + local tail = string.match(k, match_string) rawset(t, k, tail) return tail end, }) + -- TODO: Consider either a faster way of getting these + -- OR we really should just cache them longer + -- OR we need a different way of keeping track of uppercase letters. local cached_uppers = setmetatable({}, { __index = function(t, k) local obj = {} for i = 1, #k do - local s = k:sub(i, i) - local s_byte = s:byte() + local s_byte = k:byte(i, i) if s_byte <= 90 and s_byte >= 65 then - obj[s] = true + obj[s_byte] = true end end |
