QPostEventList: de-inline addEvent()
While in a private header, it did manage to place QList<QPostEvent> operations near the top spots of all Qt template instantiations in a QtWidgets build. Task-number: QTBUG-97601 Change-Id: I4fa1972b8764b71ad0559633131e7e44b3d4ae6a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 1a030f6609ad6a9bbc1253e9e2d5efb198dc5998) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
841f04f309
commit
01fd23f986
@ -18,6 +18,29 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
/*
|
||||||
|
QPostEventList
|
||||||
|
*/
|
||||||
|
|
||||||
|
void QPostEventList::addEvent(const QPostEvent &ev)
|
||||||
|
{
|
||||||
|
int priority = ev.priority;
|
||||||
|
if (isEmpty() ||
|
||||||
|
constLast().priority >= priority ||
|
||||||
|
insertionOffset >= size()) {
|
||||||
|
// optimization: we can simply append if the last event in
|
||||||
|
// the queue has higher or equal priority
|
||||||
|
append(ev);
|
||||||
|
} else {
|
||||||
|
// insert event in descending priority order, using upper
|
||||||
|
// bound for a given priority (to ensure proper ordering
|
||||||
|
// of events with the same priority)
|
||||||
|
QPostEventList::iterator at = std::upper_bound(begin() + insertionOffset, end(), ev);
|
||||||
|
insert(at, ev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
QThreadData
|
QThreadData
|
||||||
*/
|
*/
|
||||||
|
@ -73,23 +73,7 @@ public:
|
|||||||
|
|
||||||
inline QPostEventList() : QList<QPostEvent>(), recursion(0), startOffset(0), insertionOffset(0) { }
|
inline QPostEventList() : QList<QPostEvent>(), recursion(0), startOffset(0), insertionOffset(0) { }
|
||||||
|
|
||||||
void addEvent(const QPostEvent &ev)
|
void addEvent(const QPostEvent &ev);
|
||||||
{
|
|
||||||
int priority = ev.priority;
|
|
||||||
if (isEmpty() ||
|
|
||||||
constLast().priority >= priority ||
|
|
||||||
insertionOffset >= size()) {
|
|
||||||
// optimization: we can simply append if the last event in
|
|
||||||
// the queue has higher or equal priority
|
|
||||||
append(ev);
|
|
||||||
} else {
|
|
||||||
// insert event in descending priority order, using upper
|
|
||||||
// bound for a given priority (to ensure proper ordering
|
|
||||||
// of events with the same priority)
|
|
||||||
QPostEventList::iterator at = std::upper_bound(begin() + insertionOffset, end(), ev);
|
|
||||||
insert(at, ev);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//hides because they do not keep that list sorted. addEvent must be used
|
//hides because they do not keep that list sorted. addEvent must be used
|
||||||
|
Loading…
x
Reference in New Issue
Block a user