From d32d4a6e0f0c571941f1fd37759ca1ebbdd5f488 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Tue, 6 Oct 2020 21:57:49 -0400 Subject: fix: Reduce memory leaks (#148) It is not 100% clear that we've gotten ALL the memory leaks, but it seems much much much better and doesn't look like it's going to die immediately or as often anymore :) --- lua/telescope/entry_manager.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lua/telescope/entry_manager.lua') diff --git a/lua/telescope/entry_manager.lua b/lua/telescope/entry_manager.lua index bca4e55..532cca2 100644 --- a/lua/telescope/entry_manager.lua +++ b/lua/telescope/entry_manager.lua @@ -71,7 +71,7 @@ function EntryManager:should_save_result(index) return index <= self.max_results end -function EntryManager:add_entry(score, entry) +function EntryManager:add_entry(picker, score, entry) score = score or 0 if score >= self.worst_acceptable_score then @@ -82,7 +82,7 @@ function EntryManager:add_entry(score, entry) self.info.looped = self.info.looped + 1 if item.score > score then - return self:insert(index, { + return self:insert(picker, index, { score = score, entry = entry, }) @@ -94,13 +94,13 @@ function EntryManager:add_entry(score, entry) end end - return self:insert({ + return self:insert(picker, { score = score, entry = entry, }) end -function EntryManager:insert(index, entry) +function EntryManager:insert(picker, index, entry) if entry == nil then entry = index index = #self.entry_state + 1 @@ -113,7 +113,7 @@ function EntryManager:insert(index, entry) self.info.inserted = self.info.inserted + 1 next_entry = self.entry_state[index] - self.set_entry(index, entry.entry) + self.set_entry(picker, index, entry.entry) self.entry_state[index] = entry last_score = entry.score -- cgit v1.2.3