Commit 7ee83dc5 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

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
parent c3fd38e1
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment