From 66ecf343568a9b8bedaab76a53870d9dfb6f4b06 Mon Sep 17 00:00:00 2001 From: kimci86 Date: Sun, 16 Jun 2024 15:50:16 +0200 Subject: [PATCH] Create a new font page in Font::loadPage only when needed --- src/SFML/Graphics/Font.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index 47c281504..c24be8b78 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -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; }