fix compilation for Qt > 5.14: QSet::fromList(QList) deprecated

Authored by jjazeix on Apr 18 2020, 9:13 AM.

Description

fix compilation for Qt > 5.14: QSet::fromList(QList) deprecated

Details

Committed
jjazeixApr 18 2020, 9:17 AM
Parents
R125:587cefd09a77: GIT_SILENT Update Appstream for new release
Branches
Unknown
Tags
Unknown
kossebau added a subscriber: kossebau.EditedApr 18 2020, 10:12 AM

Hi. For the new code variant you might want to follow the idea hehind the change of the QSet API, and avoids the intermediate QList<QString> creation (here and in similar changes):

#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
return QSet<QString>::fromList( mRanges.uniqueKeys() );
#else
  return QSet<QString>( mRanges.keyBegin(), mRanges.keyEnd() );
#endif

More performant (no mallocs for the intermediate list), and less code to write & read :) The iterators over the keys are const methods, so no detaching is done.

Hi. For the new code variant you might want to follow the idea hehind the change of the QSet API, and avoids the intermediate QList<QString> creation (here and in similar changes):

#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
return QSet<QString>::fromList( mRanges.uniqueKeys() );
#else
  return QSet<QString>( mRanges.keyBegin(), mRanges.keyEnd() );
#endif

More performant (no mallocs for the intermediate list), and less code to write & read :) The iterators over the keys are const methods, so no detaching is done.

Thank you, I didn't know.
Do you want me to do the changes as it is better?

Yes, IMHO would be good to do, to spread usage/knowledge about the better code.

Yes, IMHO would be good to do, to spread usage/knowledge about the better code.

Thanks, it's pushed in 0a26fa2ca84c6c0bf84a8531b739e9636888e555

Thank you for your work :)