diff options
author | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-02-15 11:16:39 +0300 |
---|---|---|
committer | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-04-08 19:35:26 +0000 |
commit | 89034600939bbfe241ba3d6136abf7bb6961db52 (patch) | |
tree | 569ed773351a496ddac552fff66859967695351f /src/widgets/widgets/qabstractbutton.cpp | |
parent | f931e5e72d4617023bbea46cba2c0d61bb1efa4f (diff) |
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 <marc.mutz@kdab.com>
Diffstat (limited to 'src/widgets/widgets/qabstractbutton.cpp')
-rw-r--r-- | src/widgets/widgets/qabstractbutton.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp index 44123d4dda..1a5b8db33c 100644 --- a/src/widgets/widgets/qabstractbutton.cpp +++ b/src/widgets/widgets/qabstractbutton.cpp @@ -188,15 +188,16 @@ QList<QAbstractButton *>QAbstractButtonPrivate::queryButtonList() const QList<QAbstractButton*>candidates = parent->findChildren<QAbstractButton *>(); if (autoExclusive) { - for (int i = candidates.count() - 1; i >= 0; --i) { - QAbstractButton *candidate = candidates.at(i); - if (!candidate->autoExclusive() + auto isNoMemberOfMyAutoExclusiveGroup = [](QAbstractButton *candidate) { + return !candidate->autoExclusive() #ifndef QT_NO_BUTTONGROUP || candidate->group() #endif - ) - candidates.removeAt(i); - } + ; + }; + candidates.erase(std::remove_if(candidates.begin(), candidates.end(), + isNoMemberOfMyAutoExclusiveGroup), + candidates.end()); } return candidates; } |