Keep ZipFile open to speed up getting file stats. (#76)

Still a bit raw, but gets the time required to determine the size of
each chapter (for reading progress) down from ~25ms to 0-1ms.

This is done by keeping the zipArchive open (so simple ;)).

Probably we don't need to cache the spine sizes anymore then...

---------

Co-authored-by: Dave Allie <dave@daveallie.com>
This commit is contained in:
Jonas Diemer
2025-12-21 04:38:51 +01:00
committed by GitHub
parent 299623927e
commit 926c786705
4 changed files with 23 additions and 47 deletions

View File

@@ -33,6 +33,7 @@ class Epub {
bool parseContentOpf(const std::string& contentOpfFilePath);
bool parseTocNcxFile();
void initializeSpineItemSizes();
static bool getItemSize(const ZipFile& zip, const std::string& itemHref, size_t* size);
public:
explicit Epub(std::string filepath, const std::string& cacheDir) : filepath(std::move(filepath)) {