diff --git a/lib/Epub/Epub/css/CssParser.cpp b/lib/Epub/Epub/css/CssParser.cpp index 3c30fd85..77ee8e77 100644 --- a/lib/Epub/Epub/css/CssParser.cpp +++ b/lib/Epub/Epub/css/CssParser.cpp @@ -803,6 +803,9 @@ bool CssParser::loadFromCache() { return false; } + // Size the bucket array up front to avoid incremental rehashes while loading rules. + rulesBySelector_.reserve(ruleCount); + auto hasRemainingBytes = [&file](const size_t neededBytes) -> bool { return static_cast(file.available()) >= neededBytes; };