From fa5242b3eefd02683d98b773f1c64da6c4379fbe Mon Sep 17 00:00:00 2001 From: Vlad Zagorodniy Date: Mon, 18 Jun 2018 15:25:58 +0300 Subject: [PATCH] [effects] Use more effectData() in BuiltInEffects Summary: While BuiltInEffects has effectData() function, many functions repeat s_effectData.at(index(effect)), which is what effectData() is doing. By using effectData(), we'll get rid of those repetitions and maybe make easier transition to other underlying data structure that stores metadata for builtin effects. Test Plan: Compiles, all enabled builtin effects are loaded and working. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D13587 (cherry picked from commit 7bfaa6e913dff867e6b6c3d4b451eb274683ca87) --- effects/effect_builtins.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/effects/effect_builtins.cpp b/effects/effect_builtins.cpp index 7198d6cf09..4513f57bda 100644 --- a/effects/effect_builtins.cpp +++ b/effects/effect_builtins.cpp @@ -692,11 +692,11 @@ static inline int index(BuiltInEffect effect) Effect *create(BuiltInEffect effect) { - const EffectData &effectData = s_effectData.at(index(effect)); - if (effectData.createFunction == nullptr) { + const EffectData &data = effectData(effect); + if (data.createFunction == nullptr) { return nullptr; } - return effectData.createFunction(); + return data.createFunction(); } bool available(const QString &name) @@ -714,11 +714,11 @@ bool supported(BuiltInEffect effect) if (effect == BuiltInEffect::Invalid) { return false; } - const EffectData &effectData = s_effectData.at(index(effect)); - if (effectData.supportedFunction == nullptr) { + const EffectData &data = effectData(effect); + if (data.supportedFunction == nullptr) { return true; } - return effectData.supportedFunction(); + return data.supportedFunction(); } bool checkEnabledByDefault(BuiltInEffect effect) @@ -726,17 +726,16 @@ bool checkEnabledByDefault(BuiltInEffect effect) if (effect == BuiltInEffect::Invalid) { return false; } - const EffectData &effectData = s_effectData.at(index(effect)); - if (effectData.enabledFunction == nullptr) { + const EffectData &data = effectData(effect); + if (data.enabledFunction == nullptr) { return true; } - return effectData.enabledFunction(); + return data.enabledFunction(); } bool enabledByDefault(BuiltInEffect effect) { - const EffectData &effectData = s_effectData.at(index(effect)); - return effectData.enabled; + return effectData(effect).enabled; } QStringList availableEffectNames() @@ -775,7 +774,7 @@ BuiltInEffect builtInForName(const QString &name) QString nameForEffect(BuiltInEffect effect) { - return s_effectData.at(index(effect)).name; + return effectData(effect).name; } const EffectData &effectData(BuiltInEffect effect)