diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-09-12 10:17:02 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-09-13 06:48:58 +0000 |
commit | 1d5e55c2a34b0d5693a148075e3840aed9cab8b7 (patch) | |
tree | b33b6605d43b06947e859a62bdca8ad332faff70 | |
parent | 9ad0e09f5bbaab8ced2ea6bb175bbd13935413cf (diff) |
Improve performance of QVariant::canConvert()
Add an early check if both types are the same.
Change-Id: If6fc60a58fce641521c083bf920e72bf3d2d4c28
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index e6262124fb..a0bbcc235e 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -3052,6 +3052,9 @@ static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject) */ bool QVariant::canConvert(int targetTypeId) const { + if (d.type == targetTypeId) + return true; + if ((targetTypeId == QMetaType::QModelIndex && d.type == QMetaType::QPersistentModelIndex) || (targetTypeId == QMetaType::QPersistentModelIndex && d.type == QMetaType::QModelIndex)) return true; |