replace DoFileSearch with optimized version

This commit is contained in:
Shawn Hoffman
2017-06-20 21:24:26 -07:00
parent f16599f4a8
commit c5fa470ad8
12 changed files with 97 additions and 34 deletions

View File

@ -196,9 +196,8 @@ void InterfaceConfigPane::LoadGUIValues()
void InterfaceConfigPane::LoadThemes()
{
auto sv = Common::DoFileSearch(
{""}, {File::GetUserPath(D_THEMES_IDX), File::GetSysDirectory() + THEMES_DIR},
/*recursive*/ false);
auto sv =
Common::DoFileSearch({File::GetUserPath(D_THEMES_IDX), File::GetSysDirectory() + THEMES_DIR});
for (const std::string& filename : sv)
{
std::string name, ext;

View File

@ -1687,7 +1687,7 @@ void CFrame::GameListChanged(wxCommandEvent& event)
break;
case IDM_PURGE_GAME_LIST_CACHE:
std::vector<std::string> filenames =
Common::DoFileSearch({".cache"}, {File::GetUserPath(D_CACHE_IDX)});
Common::DoFileSearch({File::GetUserPath(D_CACHE_IDX)}, {".cache"});
for (const std::string& filename : filenames)
{

View File

@ -743,10 +743,9 @@ void GameListCtrl::RescanList()
const std::vector<std::string> search_extensions = {".gcm", ".tgc", ".iso", ".ciso", ".gcz",
".wbfs", ".wad", ".dol", ".elf"};
// TODO This could process paths iteratively as they are found
auto search_results = Common::DoFileSearch(search_extensions, SConfig::GetInstance().m_ISOFolder,
auto search_results = Common::DoFileSearch(SConfig::GetInstance().m_ISOFolder, search_extensions,
SConfig::GetInstance().m_RecursiveISOFolder);
// TODO rethink some good algorithms to use here
std::vector<std::string> cached_paths;
for (const auto& file : m_cached_files)
cached_paths.emplace_back(file->GetFileName());
@ -761,14 +760,8 @@ void GameListCtrl::RescanList()
cached_paths.cend(), std::back_inserter(new_paths));
const Core::TitleDatabase title_database;
// TODO we could store all paths and modification times to judge if file needs to be rescanned.
// If we cached paths that turned out to be invalid, this would save failing on them each time
// refresh is done.
// However if people e.g. set dolphin to recursively scan the root of their drive(s), then we
// would cache way too much data. Maybe just use an upper bound of invalid paths to cache?
// For now, only scan new_paths. This could cause false negatives (file actively being written),
// but otherwise
// should be fine.
// but otherwise should be fine.
for (const auto& path : removed_paths)
{
auto it = std::find_if(

View File

@ -7,6 +7,7 @@
#include <cstddef>
#include <memory>
#include <string>
#include <thread>
#include <vector>
#include <wx/listctrl.h>
@ -14,6 +15,7 @@
#include "Common/ChunkFile.h"
#include "Common/Event.h"
#include "Common/Flag.h"
#include "DolphinWX/ISOFile.h"
class wxEmuStateTip : public wxTipWindow

View File

@ -264,7 +264,7 @@ void InputConfigDialog::UpdateProfileComboBox()
pname += PROFILES_PATH;
pname += m_config.GetProfileName();
std::vector<std::string> sv = Common::DoFileSearch({".ini"}, {pname});
std::vector<std::string> sv = Common::DoFileSearch({pname}, {".ini"});
wxArrayString strs;
for (const std::string& filename : sv)