From 6f218ce216021ff2e8ecf828b2f29b1b9d82b401 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Tue, 2 Jun 2009 14:00:03 +0200 Subject: Microoptimize: make this function inline. Also change the order of comparisons, as the transformable flags are most likely to fail first. --- src/gui/graphicsview/qgraphicsitem.cpp | 16 ++-------------- src/gui/graphicsview/qgraphicsitem_p.h | 6 +++++- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 17cab45..ca39713 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -779,18 +779,6 @@ QPointF QGraphicsItemPrivate::genericMapFromScene(const QPointF &pos, /*! \internal - Returns true if this item or any of its ancestors are untransformable. -*/ -bool QGraphicsItemPrivate::itemIsUntransformable() const -{ - return (flags & QGraphicsItem::ItemIgnoresTransformations) - || (ancestorFlags & AncestorIgnoresTransformations); -} - - -/*! - \internal - Combines this item's position and transform onto \a transform. If you need to change this function (e.g., adding more transformation @@ -799,7 +787,7 @@ bool QGraphicsItemPrivate::itemIsUntransformable() const void QGraphicsItemPrivate::combineTransformToParent(QTransform *x, const QTransform *viewTransform) const { // COMBINE - if (viewTransform && itemIsUntransformable()) { + if (itemIsUntransformable() && viewTransform) { *x = q_ptr->deviceTransform(*viewTransform); } else { if (transform) @@ -821,7 +809,7 @@ void QGraphicsItemPrivate::combineTransformToParent(QTransform *x, const QTransf void QGraphicsItemPrivate::combineTransformFromParent(QTransform *x, const QTransform *viewTransform) const { // COMBINE - if (viewTransform && itemIsUntransformable()) { + if (itemIsUntransformable() && viewTransform) { *x = q_ptr->deviceTransform(*viewTransform); } else { x->translate(pos.x(), pos.y()); diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index d962ad0..61f6496 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -160,7 +160,11 @@ public: void setIsMemberOfGroup(bool enabled); void remapItemPos(QEvent *event, QGraphicsItem *item); QPointF genericMapFromScene(const QPointF &pos, const QWidget *viewport) const; - bool itemIsUntransformable() const; + inline bool itemIsUntransformable() const + { + return (flags & QGraphicsItem::ItemIgnoresTransformations) + || (ancestorFlags & AncestorIgnoresTransformations); + } void combineTransformToParent(QTransform *x, const QTransform *viewTransform = 0) const; void combineTransformFromParent(QTransform *x, const QTransform *viewTransform = 0) const; -- cgit v0.12