mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
GameFileCache: Pass std::function by reference rather than by value
std::function is internally allowed to allocate, and these functions aren't being stored anywhere (only called), so we can freely get rid of some minor overhead here by passing by reference. This change also creates aliases for the functions, so that there isn't a lot of visual noise when reading the function signatures.
This commit is contained in:
@ -43,7 +43,7 @@ GameFileCache::GameFileCache() : m_path(File::GetUserPath(D_CACHE_IDX) + "gameli
|
||||
{
|
||||
}
|
||||
|
||||
void GameFileCache::ForEach(std::function<void(const std::shared_ptr<const GameFile>&)> f) const
|
||||
void GameFileCache::ForEach(const ForEachFn& f) const
|
||||
{
|
||||
for (const std::shared_ptr<GameFile>& item : m_cached_files)
|
||||
f(item);
|
||||
@ -83,11 +83,10 @@ std::shared_ptr<const GameFile> GameFileCache::AddOrGet(const std::string& path,
|
||||
return result;
|
||||
}
|
||||
|
||||
bool GameFileCache::Update(
|
||||
const std::vector<std::string>& all_game_paths,
|
||||
std::function<void(const std::shared_ptr<const GameFile>&)> game_added_to_cache,
|
||||
std::function<void(const std::string&)> game_removed_from_cache,
|
||||
const std::atomic_bool& processing_halted)
|
||||
bool GameFileCache::Update(const std::vector<std::string>& all_game_paths,
|
||||
const GameAddedToCacheFn& game_added_to_cache,
|
||||
const GameRemovedFromCacheFn& game_removed_from_cache,
|
||||
const std::atomic_bool& processing_halted)
|
||||
{
|
||||
// Copy game paths into a set, except ones that match DiscIO::ShouldHideFromGameList.
|
||||
// TODO: Prevent DoFileSearch from looking inside /files/ directories of DirectoryBlobs at all?
|
||||
@ -151,9 +150,8 @@ bool GameFileCache::Update(
|
||||
return cache_changed;
|
||||
}
|
||||
|
||||
bool GameFileCache::UpdateAdditionalMetadata(
|
||||
std::function<void(const std::shared_ptr<const GameFile>&)> game_updated,
|
||||
const std::atomic_bool& processing_halted)
|
||||
bool GameFileCache::UpdateAdditionalMetadata(const GameUpdatedFn& game_updated,
|
||||
const std::atomic_bool& processing_halted)
|
||||
{
|
||||
bool cache_changed = false;
|
||||
|
||||
|
Reference in New Issue
Block a user