Skip to content

Commit

Permalink
Early-outs in IconCache
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Sep 10, 2023
1 parent 626d901 commit c343c19
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Common/UI/IconCache.cpp
Expand Up @@ -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<std::mutex> lock(lock_);

if (key.empty()) {
return false;
}
Expand All @@ -244,6 +242,7 @@ bool IconCache::InsertIcon(const std::string &key, IconFormat format, std::strin
return false;
}

std::unique_lock<std::mutex> lock(lock_);
if (cache_.find(key) != cache_.end()) {
// Already have this entry.
return false;
Expand All @@ -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<std::mutex> lock(lock_);
auto iter = cache_.find(key);
if (iter == cache_.end()) {
Expand Down

0 comments on commit c343c19

Please sign in to comment.