Create a new font page in Font::loadPage only when needed

This commit is contained in:
kimci86 2024-06-16 15:50:16 +02:00 committed by Vittorio Romeo
parent f96bf1f300
commit 66ecf34356

View File

@ -464,9 +464,12 @@ bool Font::isSmooth() const
////////////////////////////////////////////////////////////
Font::Page& Font::loadPage(unsigned int characterSize) const
{
if (const auto it = m_pages.find(characterSize); it != m_pages.end())
return it->second;
auto page = Page::make(m_isSmooth);
assert(page && "Font::loadPage() Failed to load page");
return m_pages.try_emplace(characterSize, std::move(*page)).first->second;
return m_pages.emplace(characterSize, std::move(*page)).first->second;
}