[effects/slidingpopups] Reserve enough memory for filtered quads

Summary: That's to avoid unnecessary reallocations.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D14085
This commit is contained in:
Vlad Zagorodniy 2018-07-13 09:53:43 +03:00
parent 461aace55f
commit a63c9ab319

View file

@ -146,6 +146,7 @@ void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& da
const double splitPoint = geo.width() - (geo.x() + geo.width() - screenRect.x() - start) + qMin(geo.width(), slideLength) * (appearing ? 1.0 - progress : progress); const double splitPoint = geo.width() - (geo.x() + geo.width() - screenRect.x() - start) + qMin(geo.width(), slideLength) * (appearing ? 1.0 - progress : progress);
data.quads = data.quads.splitAtX(splitPoint); data.quads = data.quads.splitAtX(splitPoint);
WindowQuadList filtered; WindowQuadList filtered;
filtered.reserve(data.quads.count());
foreach (const WindowQuad &quad, data.quads) { foreach (const WindowQuad &quad, data.quads) {
if (quad.left() >= splitPoint) { if (quad.left() >= splitPoint) {
filtered << quad; filtered << quad;
@ -158,6 +159,7 @@ void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& da
const double splitPoint = geo.height() - (geo.y() + geo.height() - screenRect.y() - start) + qMin(geo.height(), slideLength) * (appearing ? 1.0 - progress : progress); const double splitPoint = geo.height() - (geo.y() + geo.height() - screenRect.y() - start) + qMin(geo.height(), slideLength) * (appearing ? 1.0 - progress : progress);
data.quads = data.quads.splitAtY(splitPoint); data.quads = data.quads.splitAtY(splitPoint);
WindowQuadList filtered; WindowQuadList filtered;
filtered.reserve(data.quads.count());
foreach (const WindowQuad &quad, data.quads) { foreach (const WindowQuad &quad, data.quads) {
if (quad.top() >= splitPoint) { if (quad.top() >= splitPoint) {
filtered << quad; filtered << quad;
@ -170,6 +172,7 @@ void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& da
const double splitPoint = screenRect.x() + screenRect.width() - geo.x() - start - qMin(geo.width(), slideLength) * (appearing ? 1.0 - progress : progress); const double splitPoint = screenRect.x() + screenRect.width() - geo.x() - start - qMin(geo.width(), slideLength) * (appearing ? 1.0 - progress : progress);
data.quads = data.quads.splitAtX(splitPoint); data.quads = data.quads.splitAtX(splitPoint);
WindowQuadList filtered; WindowQuadList filtered;
filtered.reserve(data.quads.count());
foreach (const WindowQuad &quad, data.quads) { foreach (const WindowQuad &quad, data.quads) {
if (quad.right() <= splitPoint) { if (quad.right() <= splitPoint) {
filtered << quad; filtered << quad;
@ -183,6 +186,7 @@ void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& da
const double splitPoint = screenRect.y() + screenRect.height() - geo.y() - start - qMin(geo.height(), slideLength) * (appearing ? 1.0 - progress : progress); const double splitPoint = screenRect.y() + screenRect.height() - geo.y() - start - qMin(geo.height(), slideLength) * (appearing ? 1.0 - progress : progress);
data.quads = data.quads.splitAtY(splitPoint); data.quads = data.quads.splitAtY(splitPoint);
WindowQuadList filtered; WindowQuadList filtered;
filtered.reserve(data.quads.count());
foreach (const WindowQuad &quad, data.quads) { foreach (const WindowQuad &quad, data.quads) {
if (quad.bottom() <= splitPoint) { if (quad.bottom() <= splitPoint) {
filtered << quad; filtered << quad;