From 89034600939bbfe241ba3d6136abf7bb6961db52 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Mon, 15 Feb 2016 11:16:39 +0300 Subject: QtBase: use erase and std::remove_if with QList and QVector ... instead of using removeAt in a loop, with quadratic complexity. Change-Id: I38b49e56b12c396db9fc0f1b75d8fb43c503a7f6 Reviewed-by: Marc Mutz --- src/widgets/styles/qwindowsstyle.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/widgets/styles') diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 23f886e5b1..f6323bb41c 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -71,6 +71,8 @@ #include #include +#include + QT_BEGIN_NAMESPACE #if defined(Q_OS_WIN) @@ -159,12 +161,11 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e) // Alt has been pressed - find all widgets that care QList l = widget->findChildren(); - for (int pos=0 ; pos < l.size() ; ++pos) { - QWidget *w = l.at(pos); - if (w->isWindow() || !w->isVisible() || - w->style()->styleHint(SH_UnderlineShortcut, 0, w)) - l.removeAt(pos); - } + auto ignorable = [](QWidget *w) { + return w->isWindow() || !w->isVisible() + || w->style()->styleHint(SH_UnderlineShortcut, 0, w); + }; + l.erase(std::remove_if(l.begin(), l.end(), ignorable), l.end()); // Update states before repainting d->seenAlt.append(widget); d->alt_down = true; -- cgit v1.2.3