Review implied changes

This commit is contained in:
jpirnay
2026-04-01 11:14:53 +02:00
parent 9cdc1b8784
commit e1fd631ced
4 changed files with 13 additions and 4 deletions
@@ -520,6 +520,7 @@ void XMLCALL ChapterHtmlSlimParser::startElement(void* userData, const XML_Char*
// Create page for image - only break if image won't fit remaining space // Create page for image - only break if image won't fit remaining space
if (self->currentPage && !self->currentPage->elements.empty() && if (self->currentPage && !self->currentPage->elements.empty() &&
(self->currentPageNextY + displayHeight > self->viewportHeight)) { (self->currentPageNextY + displayHeight > self->viewportHeight)) {
self->paragraphIndexPerPage.push_back(self->xpathParagraphIndex);
self->completePageFn(std::move(self->currentPage)); self->completePageFn(std::move(self->currentPage));
self->completedPageCount++; self->completedPageCount++;
self->currentPage.reset(new Page()); self->currentPage.reset(new Page());
@@ -99,6 +99,13 @@ std::string makeSpineCacheKey(const std::shared_ptr<Epub>& epub, const int spine
size_t getTotalTextBytesCached(const std::shared_ptr<Epub>& epub, const int spineIndex, const std::string& tmpPath) { size_t getTotalTextBytesCached(const std::shared_ptr<Epub>& epub, const int spineIndex, const std::string& tmpPath) {
static std::unordered_map<std::string, size_t> sTotalBytesBySpine; static std::unordered_map<std::string, size_t> sTotalBytesBySpine;
static std::string sCachedBookPath;
const std::string currentBookPath = epub ? epub->getCachePath() : std::string();
if (currentBookPath != sCachedBookPath) {
sTotalBytesBySpine.clear();
sCachedBookPath = currentBookPath;
}
const std::string key = makeSpineCacheKey(epub, spineIndex); const std::string key = makeSpineCacheKey(epub, spineIndex);
if (!key.empty()) { if (!key.empty()) {
@@ -3,6 +3,7 @@
#include <HalStorage.h> #include <HalStorage.h>
#include <Logging.h> #include <Logging.h>
#include <algorithm>
#include <cctype> #include <cctype>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
@@ -10,9 +11,8 @@
namespace ChapterXPathIndexerInternal { namespace ChapterXPathIndexerInternal {
std::string toLowerStr(std::string value) { std::string toLowerStr(std::string value) {
for (char& c : value) { std::transform(value.begin(), value.end(), value.begin(),
c = static_cast<char>(std::tolower(static_cast<unsigned char>(c))); [](unsigned char c) { return static_cast<char>(std::tolower(c)); });
}
return value; return value;
} }
@@ -186,7 +186,7 @@ std::string decompressToTempFile(const std::shared_ptr<Epub>& epub, const int sp
return ""; return "";
} }
const std::string tmpPath = epub->getCachePath() + "/.tmp_kox.html"; const std::string tmpPath = epub->getCachePath() + "/.tmp_kox_" + std::to_string(spineIndex) + ".html";
if (Storage.exists(tmpPath.c_str())) { if (Storage.exists(tmpPath.c_str())) {
Storage.remove(tmpPath.c_str()); Storage.remove(tmpPath.c_str());
} }
@@ -15,6 +15,7 @@ namespace ChapterXPathIndexerInternal {
struct StackNode { struct StackNode {
std::string tag; std::string tag;
int index = 1; int index = 1;
// Reserved for future text-node heuristics; intentionally unused for now.
bool hasText = false; bool hasText = false;
}; };