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>
This commit is contained in:
Anton Kudryavtsev 2015-12-24 17:18:48 +03:00
parent aca299715f
commit 03dcc5c036

View File

@ -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();