Use std::find_if in EffectsHandlerImpl::isEffectLoaded
Summary: Don't use raw loops. Use appropriate algorithm from STL to find out whether effect with the given name is loaded. (also, this change deletes duplicated logic) Reviewers: #kwin, broulik, romangg Reviewed By: #kwin, broulik, romangg Subscribers: broulik, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D13836
This commit is contained in:
parent
c3fd38e182
commit
7ee83dc5e4
1 changed files with 5 additions and 10 deletions
15
effects.cpp
15
effects.cpp
|
@ -1369,20 +1369,15 @@ void EffectsHandlerImpl::reconfigureEffect(const QString& name)
|
|||
|
||||
bool EffectsHandlerImpl::isEffectLoaded(const QString& name) const
|
||||
{
|
||||
for (QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it)
|
||||
if ((*it).first == name)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
auto it = std::find_if(loaded_effects.constBegin(), loaded_effects.constEnd(),
|
||||
[&name](const EffectPair &pair) { return pair.first == name; });
|
||||
return it != loaded_effects.constEnd();
|
||||
}
|
||||
|
||||
bool EffectsHandlerImpl::isEffectSupported(const QString &name)
|
||||
{
|
||||
// if the effect is loaded, it is obviously supported
|
||||
auto it = std::find_if(loaded_effects.constBegin(), loaded_effects.constEnd(), [name](const EffectPair &pair) {
|
||||
return pair.first == name;
|
||||
});
|
||||
if (it != loaded_effects.constEnd()) {
|
||||
// If the effect is loaded, it is obviously supported.
|
||||
if (isEffectLoaded(name)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue