try_emplace in Font::loadPage

This commit is contained in:
CosminPerRam 2022-05-04 01:46:00 +03:00 committed by Lukas Dürrenberger
parent c0a6cf1f0c
commit 27a82e733b

View File

@ -534,12 +534,7 @@ void Font::cleanup()
////////////////////////////////////////////////////////////
Font::Page& Font::loadPage(unsigned int characterSize) const
{
// TODO: Remove this method and use try_emplace instead when updating to C++17
PageTable::iterator pageIterator = m_pages.find(characterSize);
if (pageIterator == m_pages.end())
pageIterator = m_pages.insert(std::make_pair(characterSize, Page(m_isSmooth))).first;
return pageIterator->second;
return m_pages.try_emplace(characterSize, Page(m_isSmooth)).first->second;
}