Cache: Rewrite based on lua-lru

Ought to be faster than our naive array-based approach.
Especially for the glyph cache, which has a solid amount of elements,
and is mostly cache hits.
(There are few things worse for performance in Lua than
table.remove @ !tail and table.insert @ !tail, which this was full of :/).

DocCache: New module that's now an actual Cache instance instead of a
weird hack. Replaces "Cache" (the instance) as used across Document &
co.
Only Cache instance with on-disk persistence.

ImageCache: Update to new Cache.

GlyphCache: Update to new Cache.
Also, actually free glyph bbs on eviction.
This commit is contained in:
NiLuJe
2021-05-04 23:13:24 +02:00
parent ce624be8b8
commit 21b067792d
15 changed files with 243 additions and 229 deletions

View File

@@ -5,10 +5,10 @@ It works using data gathered from a document interface.
]]--
local BD = require("ui/bidi")
local Cache = require("cache")
local ConfirmBox = require("ui/widget/confirmbox")
local Device = require("device")
local DeviceListener = require("device/devicelistener")
local DocCache = require("document/doccache")
local DocSettings = require("docsettings")
local DocumentRegistry = require("document/documentregistry")
local Event = require("ui/event")
@@ -733,8 +733,8 @@ function ReaderUI:onClose(full_refresh)
if self.dialog ~= self then
self:saveSettings()
end
-- serialize last used items for later launch
Cache:serialize()
-- Serialize the most recently displayed page for later launch
DocCache:serialize()
if self.document ~= nil then
logger.dbg("closing document")
self:notifyCloseDocument()