From c343c194fff227525f41a9a09f4896412ec0179c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 11 Sep 2023 00:31:41 +0200 Subject: [PATCH] Early-outs in IconCache --- Common/UI/IconCache.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Common/UI/IconCache.cpp b/Common/UI/IconCache.cpp index 830655e3df..1aa23fac6e 100644 --- a/Common/UI/IconCache.cpp +++ b/Common/UI/IconCache.cpp @@ -232,8 +232,6 @@ void IconCache::Cancel(const std::string &key) { } bool IconCache::InsertIcon(const std::string &key, IconFormat format, std::string &&data) { - std::unique_lock lock(lock_); - if (key.empty()) { return false; } @@ -244,6 +242,7 @@ bool IconCache::InsertIcon(const std::string &key, IconFormat format, std::strin return false; } + std::unique_lock lock(lock_); if (cache_.find(key) != cache_.end()) { // Already have this entry. return false; @@ -261,6 +260,10 @@ bool IconCache::InsertIcon(const std::string &key, IconFormat format, std::strin } Draw::Texture *IconCache::BindIconTexture(UIContext *context, const std::string &key) { + if (key.empty()) { + return nullptr; + } + std::unique_lock lock(lock_); auto iter = cache_.find(key); if (iter == cache_.end()) {