From 5de63109f548eee20df1fcf8b705b3471b005238 Mon Sep 17 00:00:00 2001 From: mae Date: Fri, 5 Mar 2010 11:53:07 +0100 Subject: optimize dynamic call-by-name away Reviewed-by: Roberto Raggi --- src/gui/graphicsview/qgraphicsscene.cpp | 20 ++++++++++++-------- src/gui/graphicsview/qgraphicsscene_p.h | 4 +++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 6bc02cc..f3de71e 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -228,6 +228,7 @@ #include #include #include +#include #include #include #include @@ -277,8 +278,6 @@ static void _q_hoverFromMouseEvent(QGraphicsSceneHoverEvent *hover, const QGraph hover->setAccepted(mouseEvent->isAccepted()); } -int QGraphicsScenePrivate::changedSignalIndex; - /*! \internal */ @@ -329,9 +328,10 @@ void QGraphicsScenePrivate::init() index = new QGraphicsSceneBspTreeIndex(q); // Keep this index so we can check for connected slots later on. - if (!changedSignalIndex) { - changedSignalIndex = signalIndex("changed(QList)"); - } + changedSignalIndex = signalIndex("changed(QList)"); + processDirtyItemsIndex = q->metaObject()->indexOfSlot("_q_processDirtyItems()"); + polishItemsIndex = q->metaObject()->indexOfSlot("_q_polishItems()"); + qApp->d_func()->scene_list.append(q); q->update(); } @@ -2537,8 +2537,10 @@ void QGraphicsScene::addItem(QGraphicsItem *item) return; } - if (d->unpolishedItems.isEmpty()) - QMetaObject::invokeMethod(this, "_q_polishItems", Qt::QueuedConnection); + if (d->unpolishedItems.isEmpty()) { + QMetaMethod method = metaObject()->method(d->polishItemsIndex); + method.invoke(this, Qt::QueuedConnection); + } d->unpolishedItems.append(item); item->d_ptr->pendingPolish = true; @@ -4892,7 +4894,9 @@ void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, b return; if (!processDirtyItemsEmitted) { - QMetaObject::invokeMethod(q_ptr, "_q_processDirtyItems", Qt::QueuedConnection); + QMetaMethod method = q_ptr->metaObject()->method(processDirtyItemsIndex); + method.invoke(q_ptr, Qt::QueuedConnection); +// QMetaObject::invokeMethod(q_ptr, "_q_processDirtyItems", Qt::QueuedConnection); processDirtyItemsEmitted = true; } diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index ca8b829..11e250e 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -87,7 +87,9 @@ public: static QGraphicsScenePrivate *get(QGraphicsScene *q); - static int changedSignalIndex; + int changedSignalIndex; + int processDirtyItemsIndex; + int polishItemsIndex; QGraphicsScene::ItemIndexMethod indexMethod; QGraphicsSceneIndex *index; -- cgit v0.12