mirror of
https://github.com/koreader/koreader
synced 2024-11-16 06:12:56 +00:00
pdfdocument: cache page text (#10450)
Updating the selection queries the same page tens of times per second. This prevents KOReader from keeping up with high-frequency input event streams. Fixes #10443. Relies on koreader/koreader-base#1612.
This commit is contained in:
parent
796574e5cd
commit
20101baef6
@ -103,10 +103,17 @@ function PdfDocument:comparePositions(pos1, pos2)
|
||||
end
|
||||
|
||||
function PdfDocument:getPageTextBoxes(pageno)
|
||||
local page = self._document:openPage(pageno)
|
||||
local text = page:getPageText()
|
||||
page:close()
|
||||
return text
|
||||
local hash = "textbox|"..self.file.."|"..pageno
|
||||
local cached = DocCache:check(hash)
|
||||
if not cached then
|
||||
local page = self._document:openPage(pageno)
|
||||
local text = page:getPageText()
|
||||
page:close()
|
||||
DocCache:insert(hash, CacheItem:new{text=text, size=text.size})
|
||||
return text
|
||||
else
|
||||
return cached.text
|
||||
end
|
||||
end
|
||||
|
||||
function PdfDocument:getPanelFromPage(pageno, pos)
|
||||
|
Loading…
Reference in New Issue
Block a user