CResourceTableModel: std::move parameters in DisplayEntryList()

We can allow for moving into this to avoid allocation churning.
This commit is contained in:
Lioncache
2025-12-07 08:21:11 -05:00
parent e7a2a10d64
commit 37907c7837
4 changed files with 12 additions and 14 deletions

View File

@@ -6,7 +6,7 @@
class CSkeletonHierarchyModel : public QAbstractItemModel
{
CSkeleton *mpSkeleton = nullptr;
const CSkeleton *mpSkeleton = nullptr;
public:
explicit CSkeletonHierarchyModel(QObject *pParent = nullptr);

View File

@@ -178,8 +178,8 @@ void CResourceTableContextMenu::ShowReferencers()
if (!mpModel->IsDisplayingUserEntryList())
mpBrowser->SetInspectedEntry(mpClickedEntry);
const QString ListDesc = tr("Referencers of \"%1\"").arg( TO_QSTRING(mpClickedEntry->CookedAssetPath().GetFileName()) );
mpModel->DisplayEntryList(EntryList, ListDesc);
QString ListDesc = tr("Referencers of \"%1\"").arg(TO_QSTRING(mpClickedEntry->CookedAssetPath().GetFileName()));
mpModel->DisplayEntryList(std::move(EntryList), std::move(ListDesc));
mpBrowser->ClearFilters();
}
@@ -192,19 +192,17 @@ void CResourceTableContextMenu::ShowDependencies()
QList<CResourceEntry*> EntryList;
for (auto Iter = Dependencies.begin(); Iter != Dependencies.end(); Iter++)
for (const auto& Dep : Dependencies)
{
CResourceEntry *pEntry = mpClickedEntry->ResourceStore()->FindEntry(*Iter);
if (pEntry)
if (auto* pEntry = mpClickedEntry->ResourceStore()->FindEntry(Dep))
EntryList.push_back(pEntry);
}
if (!mpModel->IsDisplayingUserEntryList())
mpBrowser->SetInspectedEntry(mpClickedEntry);
const QString ListDesc = tr("Dependencies of \"%1\"").arg( TO_QSTRING(mpClickedEntry->CookedAssetPath().GetFileName()) );
mpModel->DisplayEntryList(EntryList, ListDesc);
QString ListDesc = tr("Dependencies of \"%1\"").arg(TO_QSTRING(mpClickedEntry->CookedAssetPath().GetFileName()));
mpModel->DisplayEntryList(std::move(EntryList), std::move(ListDesc));
mpBrowser->ClearFilters();
}
@@ -222,7 +220,7 @@ void CResourceTableContextMenu::Delete()
Resources.push_back(mpModel->IndexEntry(kIndex));
}
mpBrowser->Delete(Resources, Directories);
mpBrowser->Delete(std::move(Resources), std::move(Directories));
}
void CResourceTableContextMenu::CopyName()

View File

@@ -249,12 +249,12 @@ void CResourceTableModel::FillEntryList(CVirtualDirectory *pDir, bool AssetListM
endResetModel();
}
void CResourceTableModel::DisplayEntryList(QList<CResourceEntry*>& rkEntries, const QString& rkListDescription)
void CResourceTableModel::DisplayEntryList(QList<CResourceEntry*> rkEntries, QString rkListDescription)
{
beginResetModel();
mEntries = rkEntries;
mEntries = std::move(rkEntries);
mDirectories.clear();
mModelDescription = rkListDescription;
mModelDescription = std::move(rkListDescription);
mIsAssetListMode = true;
mIsDisplayingUserEntryList = true;
endResetModel();

View File

@@ -43,7 +43,7 @@ public:
bool IsIndexDirectory(const QModelIndex& rkIndex) const;
bool HasParentDirectoryEntry() const;
void FillEntryList(CVirtualDirectory *pDir, bool AssetListMode);
void DisplayEntryList(QList<CResourceEntry*>& rkEntries, const QString& rkListDescription);
void DisplayEntryList(QList<CResourceEntry*> rkEntries, QString rkListDescription);
protected:
void RecursiveAddDirectoryContents(CVirtualDirectory *pDir);
int EntryListIndex(CResourceEntry *pEntry);