From 4aa19c2e91898ae22d39bb346c35763b7564c4f4 Mon Sep 17 00:00:00 2001 From: Vlad Zagorodniy Date: Sat, 14 Jul 2018 22:48:45 +0300 Subject: [PATCH] [effects/magiclamp] Eliminate unnecessary reallocations Summary: The maximum size of `newQuads` is known in advance, so we can avoid unnecessary reallocations when adding transformed window quads to `newQuads`. Test Plan: Minimized/unminimized System Settings. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: davidedmundson, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D14117 --- effects/magiclamp/magiclamp.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/effects/magiclamp/magiclamp.cpp b/effects/magiclamp/magiclamp.cpp index ed95884a6c..e3821560da 100644 --- a/effects/magiclamp/magiclamp.cpp +++ b/effects/magiclamp/magiclamp.cpp @@ -198,6 +198,7 @@ void MagicLampEffect::paintWindow(EffectWindow* w, int mask, QRegion region, Win quad[3]._SET_B_(quad[3]._B_() + offset[_O3_]) WindowQuadList newQuads; + newQuads.reserve(data.quads.count()); float quadFactor; // defines how fast a quad is vertically moved: y coordinates near to window top are slowed down // it is used as quadFactor^3/windowHeight^3 // quadFactor is the y position of the quad but is changed towards becomming the window height