Skip to content

Commit

Permalink
perf: remove extra map/filter in RgSource:get_completions (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikavilpas authored Nov 3, 2024
1 parent 16598dd commit df013b4
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lua/blink-cmp-rg/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,12 @@ function RgSource:get_completions(context, resolve)
vim.iter(lines)
:map(function(line)
local ok, item = pcall(vim.json.decode, line)
return ok and item or {}
end)
:filter(function(item)
return item.type == "match"
end)
:map(function(item)
return item.data.submatches
item = ok and item or {}
if item.type == "match" then
return item.data.submatches
else
return {}
end
end)
:flatten()
:each(function(submatch)
Expand Down

0 comments on commit df013b4

Please sign in to comment.