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 class CSkeletonHierarchyModel : public QAbstractItemModel
{ {
CSkeleton *mpSkeleton = nullptr; const CSkeleton *mpSkeleton = nullptr;
public: public:
explicit CSkeletonHierarchyModel(QObject *pParent = nullptr); explicit CSkeletonHierarchyModel(QObject *pParent = nullptr);

View File

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

View File

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

View File

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