diff options
| author | 2020-09-23 11:20:10 -0400 | |
|---|---|---|
| committer | 2020-09-23 11:20:12 -0400 | |
| commit | d264b7375cd2542ab92137f705af806a8de842fd (patch) | |
| tree | 7628640ac812263379deba99d85f6ba23e230828 | |
| parent | Merge pull request #4698 from lioncash/optional-null (diff) | |
| download | yuzu-d264b7375cd2542ab92137f705af806a8de842fd.tar.gz yuzu-d264b7375cd2542ab92137f705af806a8de842fd.tar.xz yuzu-d264b7375cd2542ab92137f705af806a8de842fd.zip | |
game_list: Eliminate redundant argument copies
Several functions can be taken by const reference to avoid copies
Diffstat (limited to '')
| -rw-r--r-- | src/yuzu/game_list.cpp | 32 | ||||
| -rw-r--r-- | src/yuzu/game_list.h | 6 |
2 files changed, 22 insertions, 16 deletions
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index 6a71d9644..12d0321db 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp | |||
| @@ -84,21 +84,24 @@ void GameListSearchField::setFilterResult(int visible, int total) { | |||
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | QString GameList::getLastFilterResultItem() const { | 86 | QString GameList::getLastFilterResultItem() const { |
| 87 | QStandardItem* folder; | ||
| 88 | QStandardItem* child; | ||
| 89 | QString file_path; | 87 | QString file_path; |
| 90 | const int folder_count = item_model->rowCount(); | 88 | const int folder_count = item_model->rowCount(); |
| 89 | |||
| 91 | for (int i = 0; i < folder_count; ++i) { | 90 | for (int i = 0; i < folder_count; ++i) { |
| 92 | folder = item_model->item(i, 0); | 91 | const QStandardItem* folder = item_model->item(i, 0); |
| 93 | const QModelIndex folder_index = folder->index(); | 92 | const QModelIndex folder_index = folder->index(); |
| 94 | const int children_count = folder->rowCount(); | 93 | const int children_count = folder->rowCount(); |
| 94 | |||
| 95 | for (int j = 0; j < children_count; ++j) { | 95 | for (int j = 0; j < children_count; ++j) { |
| 96 | if (!tree_view->isRowHidden(j, folder_index)) { | 96 | if (tree_view->isRowHidden(j, folder_index)) { |
| 97 | child = folder->child(j, 0); | 97 | continue; |
| 98 | file_path = child->data(GameListItemPath::FullPathRole).toString(); | ||
| 99 | } | 98 | } |
| 99 | |||
| 100 | const QStandardItem* child = folder->child(j, 0); | ||
| 101 | file_path = child->data(GameListItemPath::FullPathRole).toString(); | ||
| 100 | } | 102 | } |
| 101 | } | 103 | } |
| 104 | |||
| 102 | return file_path; | 105 | return file_path; |
| 103 | } | 106 | } |
| 104 | 107 | ||
| @@ -411,7 +414,7 @@ bool GameList::isEmpty() const { | |||
| 411 | return !item_model->invisibleRootItem()->hasChildren(); | 414 | return !item_model->invisibleRootItem()->hasChildren(); |
| 412 | } | 415 | } |
| 413 | 416 | ||
| 414 | void GameList::DonePopulating(QStringList watch_list) { | 417 | void GameList::DonePopulating(const QStringList& watch_list) { |
| 415 | emit ShowList(!isEmpty()); | 418 | emit ShowList(!isEmpty()); |
| 416 | 419 | ||
| 417 | item_model->invisibleRootItem()->appendRow(new GameListAddDir()); | 420 | item_model->invisibleRootItem()->appendRow(new GameListAddDir()); |
| @@ -472,7 +475,7 @@ void GameList::PopupContextMenu(const QPoint& menu_location) { | |||
| 472 | context_menu.exec(tree_view->viewport()->mapToGlobal(menu_location)); | 475 | context_menu.exec(tree_view->viewport()->mapToGlobal(menu_location)); |
| 473 | } | 476 | } |
| 474 | 477 | ||
| 475 | void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, std::string path) { | 478 | void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, const std::string& path) { |
| 476 | QAction* open_save_location = context_menu.addAction(tr("Open Save Data Location")); | 479 | QAction* open_save_location = context_menu.addAction(tr("Open Save Data Location")); |
| 477 | QAction* open_mod_location = context_menu.addAction(tr("Open Mod Data Location")); | 480 | QAction* open_mod_location = context_menu.addAction(tr("Open Mod Data Location")); |
| 478 | QAction* open_transferable_shader_cache = | 481 | QAction* open_transferable_shader_cache = |
| @@ -690,12 +693,15 @@ void GameList::SaveInterfaceLayout() { | |||
| 690 | } | 693 | } |
| 691 | 694 | ||
| 692 | void GameList::LoadInterfaceLayout() { | 695 | void GameList::LoadInterfaceLayout() { |
| 693 | auto header = tree_view->header(); | 696 | auto* header = tree_view->header(); |
| 694 | if (!header->restoreState(UISettings::values.gamelist_header_state)) { | 697 | |
| 695 | // We are using the name column to display icons and titles | 698 | if (header->restoreState(UISettings::values.gamelist_header_state)) { |
| 696 | // so make it as large as possible as default. | 699 | return; |
| 697 | header->resizeSection(COLUMN_NAME, header->width()); | ||
| 698 | } | 700 | } |
| 701 | |||
| 702 | // We are using the name column to display icons and titles | ||
| 703 | // so make it as large as possible as default. | ||
| 704 | header->resizeSection(COLUMN_NAME, header->width()); | ||
| 699 | } | 705 | } |
| 700 | 706 | ||
| 701 | const QStringList GameList::supported_file_extensions = { | 707 | const QStringList GameList::supported_file_extensions = { |
diff --git a/src/yuzu/game_list.h b/src/yuzu/game_list.h index 78e2ba169..63aae2111 100644 --- a/src/yuzu/game_list.h +++ b/src/yuzu/game_list.h | |||
| @@ -82,7 +82,7 @@ public: | |||
| 82 | static const QStringList supported_file_extensions; | 82 | static const QStringList supported_file_extensions; |
| 83 | 83 | ||
| 84 | signals: | 84 | signals: |
| 85 | void GameChosen(QString game_path); | 85 | void GameChosen(const QString& game_path); |
| 86 | void ShouldCancelWorker(); | 86 | void ShouldCancelWorker(); |
| 87 | void OpenFolderRequested(u64 program_id, GameListOpenTarget target, | 87 | void OpenFolderRequested(u64 program_id, GameListOpenTarget target, |
| 88 | const std::string& game_path); | 88 | const std::string& game_path); |
| @@ -108,12 +108,12 @@ private: | |||
| 108 | void AddDirEntry(GameListDir* entry_items); | 108 | void AddDirEntry(GameListDir* entry_items); |
| 109 | void AddEntry(const QList<QStandardItem*>& entry_items, GameListDir* parent); | 109 | void AddEntry(const QList<QStandardItem*>& entry_items, GameListDir* parent); |
| 110 | void ValidateEntry(const QModelIndex& item); | 110 | void ValidateEntry(const QModelIndex& item); |
| 111 | void DonePopulating(QStringList watch_list); | 111 | void DonePopulating(const QStringList& watch_list); |
| 112 | 112 | ||
| 113 | void RefreshGameDirectory(); | 113 | void RefreshGameDirectory(); |
| 114 | 114 | ||
| 115 | void PopupContextMenu(const QPoint& menu_location); | 115 | void PopupContextMenu(const QPoint& menu_location); |
| 116 | void AddGamePopup(QMenu& context_menu, u64 program_id, std::string path); | 116 | void AddGamePopup(QMenu& context_menu, u64 program_id, const std::string& path); |
| 117 | void AddCustomDirPopup(QMenu& context_menu, QModelIndex selected); | 117 | void AddCustomDirPopup(QMenu& context_menu, QModelIndex selected); |
| 118 | void AddPermDirPopup(QMenu& context_menu, QModelIndex selected); | 118 | void AddPermDirPopup(QMenu& context_menu, QModelIndex selected); |
| 119 | 119 | ||