Skip to content

Commit 311ba47

Browse files
committed
Cache get_non_scrollview_floats
1 parent 3ae13a8 commit 311ba47

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lua/scrollview.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ local PROPER_LINE_COUNT_KEY_PREFIX = 1
125125
local TOPLINE_LOOKUP_KEY_PREFIX = 2
126126
local GET_WINDOW_EDGES_KEY_PREFIX = 3
127127
local ROW_LENGTH_LOOKUP_KEY_PREFIX = 4
128+
-- For get_non_scrollview_floats, a prefix is not necessary, since the function
129+
-- takes no arguments.
130+
local GET_NON_SCROLLVIEW_FLOATS_KEY = 5
128131

129132
-- Maps window ID and highlight group to a temporary highlight group with the
130133
-- corresponding definition. This is reset on each refresh cycle.
@@ -372,12 +375,15 @@ local get_floating_windows = function()
372375
end
373376

374377
local get_non_scrollview_floats = function()
378+
local memoize_key = GET_NON_SCROLLVIEW_FLOATS_KEY
379+
if memoize and cache[memoize_key] then return cache[memoize_key] end
375380
local result = {}
376381
for _, winid in ipairs(get_floating_windows()) do
377382
if not is_scrollview_window(winid) then
378383
table.insert(result, winid)
379384
end
380385
end
386+
if memoize then cache[memoize_key] = result end
381387
return result
382388
end
383389

0 commit comments

Comments
 (0)