From 697180dda09a5c8d15910165d9722cae1559ad5a Mon Sep 17 00:00:00 2001 From: Raul Fernandes Date: Tue, 19 Nov 2013 09:49:17 -0200 Subject: [PATCH] Avoids unnecessary searchs for info of the window We already have the info variable. Why search for it again? Patch reviewed in https://git.reviewboard.kde.org/r/113872/ --- effects/glide/glide.cpp | 22 ++++++++-------------- effects/glide/glide.h | 4 ++-- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/effects/glide/glide.cpp b/effects/glide/glide.cpp index 18c1e376e3..b133858159 100644 --- a/effects/glide/glide.cpp +++ b/effects/glide/glide.cpp @@ -110,38 +110,32 @@ void GlideEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowP default: case GlideInOut: if (info->added) - glideIn(w, data); + glideIn(w, data, info); else if (info->closed) - glideOut(w, data); + glideOut(w, data, info); break; case GlideOutIn: if (info->added) - glideOut(w, data); + glideOut(w, data, info); if (info->closed) - glideIn(w, data); + glideIn(w, data, info); break; - case GlideIn: glideIn(w, data); break; - case GlideOut: glideOut(w, data); break; + case GlideIn: glideIn(w, data, info); break; + case GlideOut: glideOut(w, data, info); break; } } effects->paintWindow(w, mask, region, data); } -void GlideEffect::glideIn(EffectWindow* w, WindowPaintData& data) +void GlideEffect::glideIn(EffectWindow* w, WindowPaintData& data, const InfoHash::const_iterator &info) { - InfoHash::const_iterator info = windows.constFind(w); - if (info == windows.constEnd()) - return; const double progress = info->timeLine->currentValue(); data *= progress; data.translate(int(w->width() / 2 * (1 - progress)), int(w->height() / 2 * (1 - progress))); } -void GlideEffect::glideOut(EffectWindow* w, WindowPaintData& data) +void GlideEffect::glideOut(EffectWindow* w, WindowPaintData& data, const InfoHash::const_iterator &info) { - InfoHash::const_iterator info = windows.constFind(w); - if (info == windows.constEnd()) - return; const double progress = info->timeLine->currentValue(); data *= (2 - progress); data.translate(- int(w->width() / 2 * (1 - progress)), - int(w->height() / 2 * (1 - progress))); diff --git a/effects/glide/glide.h b/effects/glide/glide.h index 352abb35b0..487fe30670 100644 --- a/effects/glide/glide.h +++ b/effects/glide/glide.h @@ -67,8 +67,8 @@ public Q_SLOTS: private: class WindowInfo; typedef QMap< const EffectWindow*, WindowInfo > InfoHash; - void glideIn(EffectWindow* w, WindowPaintData& data); - void glideOut(EffectWindow* w, WindowPaintData& data); + void glideIn(EffectWindow* w, WindowPaintData& data, const InfoHash::const_iterator &info); + void glideOut(EffectWindow* w, WindowPaintData& data, const InfoHash::const_iterator &info); bool isGlideWindow(EffectWindow* w); InfoHash windows; float duration;