summaryrefslogtreecommitdiffstats
path: root/src/gui/accessible/qaccessiblecache_p.h
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2016-07-04 15:21:19 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-07-07 14:50:00 +0000
commitb6c10cf33107309f13c9845495d9d7d4f45f34bf (patch)
tree3d2681f8c6435752ddd81b33d44687381ecfa8af /src/gui/accessible/qaccessiblecache_p.h
parent3658354a7de9615bdf03b49736fea3ec41cecd77 (diff)
Improve lookup speed for QAccessible::uniqueId
When QAccessible::uniqueId was called, it would call QHash::key(), which has linear time performance. This can cause application slowdown if a big number of QAccessibleInterface Ids have to be found. The patch adds an additional QHash to keep track of the inverse relationship from QAccessibleInterface pointers to their Ids. Change-Id: I975e3dc0e6c628e2ea701323d8b87184ad133cfb Task-number: QTBUG-54491 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'src/gui/accessible/qaccessiblecache_p.h')
-rw-r--r--src/gui/accessible/qaccessiblecache_p.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/gui/accessible/qaccessiblecache_p.h b/src/gui/accessible/qaccessiblecache_p.h
index ffaccbca42..bb33ea2cd4 100644
--- a/src/gui/accessible/qaccessiblecache_p.h
+++ b/src/gui/accessible/qaccessiblecache_p.h
@@ -64,6 +64,7 @@ class Q_GUI_EXPORT QAccessibleCache :public QObject
public:
static QAccessibleCache *instance();
QAccessibleInterface *interfaceForId(QAccessible::Id id) const;
+ QAccessible::Id idForInterface(QAccessibleInterface *iface) const;
QAccessible::Id insert(QObject *object, QAccessibleInterface *iface) const;
void deleteInterface(QAccessible::Id id, QObject *obj = 0);
@@ -79,6 +80,7 @@ private:
QAccessible::Id acquireId() const;
mutable QHash<QAccessible::Id, QAccessibleInterface *> idToInterface;
+ mutable QHash<QAccessibleInterface *, QAccessible::Id> interfaceToId;
mutable QHash<QObject *, QAccessible::Id> objectToId;
#ifdef Q_OS_MAC