Skip to content

Commit

Permalink
pull changes from upstream: use hrtime instead of os.clock
Browse files Browse the repository at this point in the history
  • Loading branch information
user committed Nov 27, 2024
1 parent a9eb780 commit 15858ec
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lua/cmp/source.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ source.get_entries = function(self, ctx)
local entries = {}
local matching_config = self:get_matching_config()
local filtering_context_budget = config.get().performance.filtering_context_budget / 1000
local s = os.clock()
local stime = (vim.uv or vim.loop).hrtime() / 1000000
for _, e in ipairs(target_entries) do
local o = e.offset
if not inputs[o] then
Expand All @@ -148,12 +148,13 @@ source.get_entries = function(self, ctx)
end
end

if os.clock() - s > filtering_context_budget then
local etime = (vim.uv or vim.loop).hrtime() / 1000000
if etime - stime > filtering_context_budget then
async.yield()
if ctx.aborted then
async.abort()
end
s = os.clock()
stime = etime
end
end

Expand Down

0 comments on commit 15858ec

Please sign in to comment.