Skip to content

Commit

Permalink
Improve performance of QVariant::canConvert()
Browse files Browse the repository at this point in the history
Add an early check if both types are the same.

Change-Id: If6fc60a58fce641521c083bf920e72bf3d2d4c28
Reviewed-by: Jędrzej Nowacki <[email protected]>
Reviewed-by: Thiago Macieira <[email protected]>
  • Loading branch information
laknoll committed Sep 13, 2017
1 parent 9ad0e09 commit 1d5e55c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/corelib/kernel/qvariant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1d5e55c

Please sign in to comment.