From 8dd6b16fee6e927627fa1adb6b5f2c2fc568ae8f Mon Sep 17 00:00:00 2001 From: elsid Date: Mon, 20 Mar 2023 00:21:41 +0100 Subject: [PATCH] Avoid double lookup --- .../contentselector/model/contentmodel.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/components/contentselector/model/contentmodel.cpp b/components/contentselector/model/contentmodel.cpp index 46b1015930..97bda943ac 100644 --- a/components/contentselector/model/contentmodel.cpp +++ b/components/contentselector/model/contentmodel.cpp @@ -580,10 +580,10 @@ void ContentSelectorModel::ContentModel::sortFiles() bool ContentSelectorModel::ContentModel::isChecked(const QString& filepath) const { - if (mCheckStates.contains(filepath)) - return (mCheckStates[filepath] == Qt::Checked); - - return false; + const auto it = mCheckStates.find(filepath); + if (it == mCheckStates.end()) + return false; + return it.value() == Qt::Checked; } bool ContentSelectorModel::ContentModel::isEnabled(const QModelIndex& index) const @@ -593,10 +593,10 @@ bool ContentSelectorModel::ContentModel::isEnabled(const QModelIndex& index) con bool ContentSelectorModel::ContentModel::isNew(const QString& filepath) const { - if (mNewFiles.contains(filepath)) - return mNewFiles[filepath]; - - return false; + const auto it = mNewFiles.find(filepath); + if (it == mNewFiles.end()) + return false; + return it.value(); } void ContentSelectorModel::ContentModel::setNew(const QString& filepath, bool isNew)