From 620f513661a2b3256c2cc204def64614b51b0b7e Mon Sep 17 00:00:00 2001 From: David Bauer Date: Sat, 9 Nov 2024 18:10:49 +0100 Subject: [PATCH] Use std::all_of in LoadAll --- src/resources.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/resources.cpp b/src/resources.cpp index 9288aa7f37..a9611ed8dc 100644 --- a/src/resources.cpp +++ b/src/resources.cpp @@ -135,18 +135,18 @@ bool Resources::AddCustom(const std::vector &extraFonts) bool Resources::LoadAll() { - bool success = true; std::string path = Resources::GetPath() + "/"; - for (const std::filesystem::directory_entry &entry : std::filesystem::directory_iterator(path)) { - const std::filesystem::path path = entry.path(); - if (path.has_extension() && path.has_stem() && path.extension() == ".xml") { - const std::string fontName = path.stem().string(); - if (!IsFontLoaded(fontName)) { - success = success && LoadFont(fontName); + return std::ranges::all_of( + std::filesystem::directory_iterator(path), [this](const std::filesystem::directory_entry &entry) { + const std::filesystem::path &path = entry.path(); + if (path.has_extension() && path.has_stem() && path.extension() == ".xml") { + const std::string fontName = path.stem().string(); + if (!this->IsFontLoaded(fontName) && !this->LoadFont(fontName)) { + return false; + } } - } - } - return success; + return true; + }); } void Resources::SetFallbackFont(const std::string &fontName) @@ -167,7 +167,7 @@ bool Resources::SetCurrentFont(const std::string &fontName, bool allowLoading) m_currentFontName = fontName; return true; } - + return false; }