From 33c7edaaf479e5d06513ce0dfe3e2de470227d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Sat, 12 Jan 2019 14:39:16 +0100 Subject: [PATCH] Use reserve on QVector Summary: We know that the maximum size is the number of windows in stacking order. It might be that some are skipped as they are not ready for painting, but overall it's better to reserve a little bit too much memory than to have a growing QVector. Test Plan: Compiles Reviewers: #kwin Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D18208 --- scene.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scene.cpp b/scene.cpp index 584be708c3..fa91f619f2 100644 --- a/scene.cpp +++ b/scene.cpp @@ -207,6 +207,7 @@ void Scene::paintGenericScreen(int orig_mask, ScreenPaintData) paintBackground(infiniteRegion()); } QVector phase2; + phase2.reserve(stacking_order.size()); foreach (Window * w, stacking_order) { // bottom to top Toplevel* topw = w->window(); @@ -250,6 +251,7 @@ void Scene::paintSimpleScreen(int orig_mask, QRegion region) assert((orig_mask & (PAINT_SCREEN_TRANSFORMED | PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS)) == 0); QVector phase2data; + phase2data.reserve(stacking_order.size()); QRegion dirtyArea = region; bool opaqueFullscreen(false);