perf: reserve CSS rule map before loading from cache (#2435)

Co-authored-by: Erica Jensen <erica@mailershaven.com>
This commit is contained in:
hooligan333
2026-07-11 22:24:43 -04:00
committed by GitHub
co-authored by Erica Jensen
parent e142e88ce7
commit e0253a8664
+3
View File
@@ -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<size_t>(file.available()) >= neededBytes;
};