Skip to content

Commit

Permalink
Simplify ThemeResources::CheckIfExists()
Browse files Browse the repository at this point in the history
Use std::unordered_map::find() instead of testing if a condition will
throw. Also fixes an MSVC warning about ignoring a nodiscard function.

Signed-off-by: Avery King <[email protected]>
  • Loading branch information
generic-pers0n committed May 12, 2024
1 parent 6269065 commit 2054ce4
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions libraries/lib-theme/ThemeResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,7 @@ std::any& ThemeResources::GetResourceData(const std::string& name)

bool ThemeResources::CheckIfExists(const std::string& name) const
{
try
{
mResources.at(name);
} catch (std::out_of_range&)
{
return false;
}

return true;
return mResources.find(name) != mResources.end();
}

ThemeResources::ThemeResourceList ThemeResources::GetRegisteredResourceNames() const
Expand Down

0 comments on commit 2054ce4

Please sign in to comment.