[clazy] [Bug 382702] Comparison between QMap keys false positive
Sergio Martins
bugzilla_noreply at kde.org
Tue Jul 25 11:28:44 BST 2017
https://bugs.kde.org/show_bug.cgi?id=382702
Sergio Martins <smartins at kde.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #1 from Sergio Martins <smartins at kde.org> ---
This is not a false positive, check
https://code.woboq.org/qt5/qtbase/src/corelib/tools/qhash.h.html#_ZNK5QHash4keysEv
to see how keys() is implemented, it allocates and fills a new container
There's no easy way, but you could do:
bool keysEqual(const QMap<int, QString> &map1, const QMap<int, QString> &map2)
{
if (map1.size() != map2.size())
return false;
for (auto it1 = map1.keyBegin(), it2 = map2.keyBegin(), e1 = map2.keyEnd();
it1 != e1; ++it1, ++it2) {
if (*it1 != *it2)
return false;
}
return true;
}
Which is a couple orders of magnitude faster
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the Unassigned-bugs
mailing list