perf: skip CSS loading in Sleep and Home activities

Both activities only need book metadata (title, author) and cover image.
Pass skipLoadingCss=true to Epub::load() to avoid unnecessary CSS
parsing and caching operations.
This commit is contained in:
Jake Kenneally 2026-02-03 19:45:12 -05:00
parent cd61b263e5
commit 9e1356bb92
2 changed files with 4 additions and 2 deletions

View File

@ -238,7 +238,8 @@ void SleepActivity::renderCoverSleepScreen() const {
} else if (StringUtils::checkFileExtension(APP_STATE.openEpubPath, ".epub")) { } else if (StringUtils::checkFileExtension(APP_STATE.openEpubPath, ".epub")) {
// Handle EPUB file // Handle EPUB file
Epub lastEpub(APP_STATE.openEpubPath, "/.crosspoint"); Epub lastEpub(APP_STATE.openEpubPath, "/.crosspoint");
if (!lastEpub.load()) { // Skip loading css since we only need metadata here
if (!lastEpub.load(true, true)) {
Serial.println("[SLP] Failed to load last epub"); Serial.println("[SLP] Failed to load last epub");
return renderDefaultSleepScreen(); return renderDefaultSleepScreen();
} }

View File

@ -52,7 +52,8 @@ void HomeActivity::onEnter() {
// If epub, try to load the metadata for title/author and cover // If epub, try to load the metadata for title/author and cover
if (StringUtils::checkFileExtension(lastBookTitle, ".epub")) { if (StringUtils::checkFileExtension(lastBookTitle, ".epub")) {
Epub epub(APP_STATE.openEpubPath, "/.crosspoint"); Epub epub(APP_STATE.openEpubPath, "/.crosspoint");
epub.load(false); // Skip loading css since we only need metadata here
epub.load(false, true);
if (!epub.getTitle().empty()) { if (!epub.getTitle().empty()) {
lastBookTitle = std::string(epub.getTitle()); lastBookTitle = std::string(epub.getTitle());
} }