Remove Plugin::GetLowercasedName()

It should only be used in certain cases, so to avoid misuse don't have
it as a method on the object.
This commit is contained in:
Oliver Hamlet
2018-10-20 12:48:21 +01:00
parent 2c079731a5
commit 9867cdee10
4 changed files with 14 additions and 9 deletions
+4 -2
View File
@@ -109,11 +109,13 @@ std::optional<std::shared_ptr<const Plugin>> GameCache::GetPlugin(
void GameCache::AddPlugin(const Plugin&& plugin) {
lock_guard<mutex> lock(mutex_);
auto it = plugins_.find(plugin.GetLowercasedName());
auto lowercasedName = to_lower(plugin.GetName());
auto it = plugins_.find(lowercasedName);
if (it != end(plugins_))
plugins_.erase(it);
plugins_.emplace(plugin.GetLowercasedName(),
plugins_.emplace(lowercasedName,
std::make_shared<Plugin>(std::move(plugin)));
}
+9 -1
View File
@@ -73,7 +73,15 @@ template<>
struct less<std::shared_ptr<const loot::Plugin>> {
bool operator()(const std::shared_ptr<const loot::Plugin>& lhs,
const std::shared_ptr<const loot::Plugin>& rhs) const {
return lhs->GetLowercasedName() < rhs->GetLowercasedName();
if (!lhs) {
return false;
}
if (!rhs) {
return true;
}
return *lhs < *rhs;
}
};
}
+1 -5
View File
@@ -131,10 +131,6 @@ Plugin::Plugin(const GameType gameType,
std::string Plugin::GetName() const { return name_; }
std::string Plugin::GetLowercasedName() const {
return boost::locale::to_lower(name_);
}
std::optional<std::string> Plugin::GetVersion() const {
std::string version = Version(GetDescription()).AsString();
if (version.empty()) {
@@ -263,7 +259,7 @@ uintmax_t Plugin::GetFileSize(std::filesystem::path pluginPath) {
}
bool Plugin::operator<(const Plugin& rhs) const {
return GetLowercasedName() < rhs.GetLowercasedName();
return boost::locale::to_lower(name_) < boost::locale::to_lower(rhs.name_);
}
bool Plugin::IsActive() const { return isActive_; }
-1
View File
@@ -50,7 +50,6 @@ public:
const bool headerOnly);
std::string GetName() const;
std::string GetLowercasedName() const;
std::optional<std::string> GetVersion() const;
std::vector<std::string> GetMasters() const;
std::set<Tag> GetBashTags() const;