diff options
author | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2015-12-24 17:18:48 +0300 |
---|---|---|
committer | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-01-09 09:06:01 +0000 |
commit | 03dcc5c036e887600a65907f1b192b06b2cc6c9b (patch) | |
tree | 76fe01579d32120f84a15e369b15b48b90abcf46 /src/plugins | |
parent | aca299715fc93b77c695cbce750f5f59ee164d9a (diff) |
QXcbConnection: use erase and std::remove_if with QVector
... instead of using erase in a loop, with quadratic complexity.
Change-Id: Ia5201e0bedca7abec6d485505f61f3f76a028bd1
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index f16bebb758..7348eaac20 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -1691,15 +1691,14 @@ void QXcbConnection::processXcbEvents() if (accepted) continue; - QVector<PeekFunc>::iterator it = m_peekFuncs.begin(); - while (it != m_peekFuncs.end()) { + auto isWaitingFor = [=](PeekFunc peekFunc) { // These callbacks return true if the event is what they were // waiting for, remove them from the list in that case. - if ((*it)(this, event)) - it = m_peekFuncs.erase(it); - else - ++it; - } + return peekFunc(this, event); + }; + m_peekFuncs.erase(std::remove_if(m_peekFuncs.begin(), m_peekFuncs.end(), + isWaitingFor), + m_peekFuncs.end()); m_reader->unlock(); handleXcbEvent(event); m_reader->lock(); |