Use `std::accumulate` in `ShellCorona::_availableScreenRegion`

Consider using std::accumulate algorithm instead of a raw loop. (CWE-398) in shell/shellcorona.cpp:1051
wilder-5.26
Fushan Wen 4 years ago
parent bd7f3bcc1b
commit 6f96fab365
No known key found for this signature in database
GPG Key ID: 2E48D1487C91DCAA
  1. 9
      shell/shellcorona.cpp

@ -1033,14 +1033,13 @@ QRegion ShellCorona::_availableScreenRegion(int id) const
return s ? s->availableGeometry() : QRegion(); return s ? s->availableGeometry() : QRegion();
} }
QRegion r = view->geometry(); return std::accumulate(m_panelViews.cbegin(), m_panelViews.cend(), QRegion(view->geometry()), [view](const QRegion &a, const PanelView *v) {
for (const PanelView *v : m_panelViews) {
if (v->isVisible() && view->screen() == v->screen() && v->visibilityMode() != PanelView::AutoHide) { if (v->isVisible() && view->screen() == v->screen() && v->visibilityMode() != PanelView::AutoHide) {
// if the panel is being moved around, we still want to calculate it from the edge // if the panel is being moved around, we still want to calculate it from the edge
r -= v->geometryByDistance(0); return a - v->geometryByDistance(0);
} }
} return a;
return r; });
} }
QRect ShellCorona::availableScreenRect(int id) const QRect ShellCorona::availableScreenRect(int id) const

Loading…
Cancel
Save