mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
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:
@@ -1,6 +1,6 @@
|
||||
local Cache = require("cache")
|
||||
local ConfirmBox = require("ui/widget/confirmbox")
|
||||
local Device = require("device")
|
||||
local DocCache = require("document/doccache")
|
||||
local Event = require("ui/event")
|
||||
local Geom = require("ui/geometry")
|
||||
local GestureRange = require("ui/gesturerange")
|
||||
@@ -458,9 +458,9 @@ function ReaderZooming:getZoom(pageno)
|
||||
or self.zoom_factor
|
||||
zoom = zoom_w * zoom_factor
|
||||
end
|
||||
if zoom and zoom > 10 and not Cache:willAccept(zoom * (self.dimen.w * self.dimen.h + 512)) then
|
||||
if zoom and zoom > 10 and not DocCache:willAccept(zoom * (self.dimen.w * self.dimen.h + 512)) then
|
||||
logger.dbg("zoom too large, adjusting")
|
||||
while not Cache:willAccept(zoom * (self.dimen.w * self.dimen.h + 512)) do
|
||||
while not DocCache:willAccept(zoom * (self.dimen.w * self.dimen.h + 512)) do
|
||||
if zoom > 100 then
|
||||
zoom = zoom - 50
|
||||
elseif zoom > 10 then
|
||||
|
||||
Reference in New Issue
Block a user