diff options
author | Giuseppe D'Angelo <dangelog@gmail.com> | 2012-03-01 23:47:36 +0000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-02 23:16:25 +0100 |
commit | 7ae38c49b78515e1e49f8a8858ce9c581e534284 (patch) | |
tree | 33815a82d11975f9fee1853ff68e95bfe4678beb /src/widgets/graphicsview/qgraphicsitem.cpp | |
parent | 95d83cb1b68cc4a415d5d80859b4e74472ad7112 (diff) |
Use QHash<K,V> instead of QMap<K,V> when K is a pointer type
Changes various internal usages of QMap when the key is a pointer type.
Being ordered by the pointer value itself, it makes very little sense
to use QMap<K*, V> (esp. in cases where the key is actually allocated
on the heap).
The usages have been found with the following script:
#!/usr/bin/perl
use strict;
use warnings;
use Regexp::Common;
use File::Find;
use feature ':5.10';
my $container = qr/(?:QMap)/;
sub process {
return unless (-f and -r and /(\.c|\.cpp|\.h|\.txt)$/);
open my $fh, "<", $_ or die "Cannot open $_: $!";
while (my $line = <$fh>) {
chomp $line;
while ($line =~ /($container\s*$RE{balanced}{-parens=>"<>"})/g) {
my $tmp = $1;
$tmp =~ s/\s+//g;
say "$_:$.: $line" if $tmp =~ /^$container\s*<[^,]+\*,/;
}
}
close $fh;
}
find( { no_chdir => 1, wanted => \&process }, @ARGV );
Change-Id: Idd9819c3f4c48f98ef92831d5e8e5ac0fa42283c
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/widgets/graphicsview/qgraphicsitem.cpp')
-rw-r--r-- | src/widgets/graphicsview/qgraphicsitem.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index d88183fbb5..dab1965da5 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -783,7 +783,7 @@ static inline void _q_adjustRect(QRect *rect) class QGraphicsItemCustomDataStore { public: - QMap<const QGraphicsItem *, QMap<int, QVariant> > data; + QHash<const QGraphicsItem *, QMap<int, QVariant> > data; }; Q_GLOBAL_STATIC(QGraphicsItemCustomDataStore, qt_dataStore) @@ -1379,7 +1379,7 @@ void QGraphicsItemCache::purge() { QPixmapCache::remove(key); key = QPixmapCache::Key(); - QMutableMapIterator<QPaintDevice *, DeviceData> it(deviceData); + QMutableHashIterator<QPaintDevice *, DeviceData> it(deviceData); while (it.hasNext()) { DeviceData &data = it.next().value(); QPixmapCache::remove(data.key); @@ -7124,7 +7124,7 @@ void QGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) if ((event->buttons() & Qt::LeftButton) && (flags() & ItemIsMovable)) { // Determine the list of items that need to be moved. QList<QGraphicsItem *> selectedItems; - QMap<QGraphicsItem *, QPointF> initialPositions; + QHash<QGraphicsItem *, QPointF> initialPositions; if (d_ptr->scene) { selectedItems = d_ptr->scene->selectedItems(); initialPositions = d_ptr->scene->d_func()->movingItemsInitialPositions; |