Recover parts of the regression fiasco
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -89,7 +89,6 @@ void FontCacheManager::recordText(const char* text, int fontId, EpdFontFamily::S
|
||||
|
||||
FontCacheManager::PrewarmScope::PrewarmScope(FontCacheManager& manager) : manager_(&manager) {
|
||||
manager_->scanMode_ = ScanMode::Scanning;
|
||||
manager_->clearCache();
|
||||
manager_->resetStats();
|
||||
manager_->scanText_.clear();
|
||||
manager_->scanText_.reserve(2048); // Pre-allocate to avoid heap fragmentation from repeated concat
|
||||
@@ -110,15 +109,13 @@ void FontCacheManager::PrewarmScope::endScanAndPrewarm() {
|
||||
|
||||
manager_->prewarmCache(manager_->scanFontId_, manager_->scanText_.c_str(), styleMask);
|
||||
|
||||
// Free scan string memory
|
||||
// Keep reserved capacity to avoid repeated alloc/free churn between pages.
|
||||
manager_->scanText_.clear();
|
||||
manager_->scanText_.shrink_to_fit();
|
||||
}
|
||||
|
||||
FontCacheManager::PrewarmScope::~PrewarmScope() {
|
||||
if (active_) {
|
||||
endScanAndPrewarm(); // no-op if already called (scanText_ is empty)
|
||||
manager_->clearCache();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user