mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-04 03:46:42 +01:00
Merge pull request #12387 from lioncash/cache
GameFileCache: Pass std::function by reference rather than by value
This commit is contained in:
commit
dd0ac7d53c
@ -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)
|
for (const std::shared_ptr<GameFile>& item : m_cached_files)
|
||||||
f(item);
|
f(item);
|
||||||
@ -83,10 +83,9 @@ std::shared_ptr<const GameFile> GameFileCache::AddOrGet(const std::string& path,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameFileCache::Update(
|
bool GameFileCache::Update(std::span<const std::string> all_game_paths,
|
||||||
const std::vector<std::string>& all_game_paths,
|
const GameAddedToCacheFn& game_added_to_cache,
|
||||||
std::function<void(const std::shared_ptr<const GameFile>&)> game_added_to_cache,
|
const GameRemovedFromCacheFn& game_removed_from_cache,
|
||||||
std::function<void(const std::string&)> game_removed_from_cache,
|
|
||||||
const std::atomic_bool& processing_halted)
|
const std::atomic_bool& processing_halted)
|
||||||
{
|
{
|
||||||
// Copy game paths into a set, except ones that match DiscIO::ShouldHideFromGameList.
|
// Copy game paths into a set, except ones that match DiscIO::ShouldHideFromGameList.
|
||||||
@ -151,8 +150,7 @@ bool GameFileCache::Update(
|
|||||||
return cache_changed;
|
return cache_changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameFileCache::UpdateAdditionalMetadata(
|
bool GameFileCache::UpdateAdditionalMetadata(const GameUpdatedFn& game_updated,
|
||||||
std::function<void(const std::shared_ptr<const GameFile>&)> game_updated,
|
|
||||||
const std::atomic_bool& processing_halted)
|
const std::atomic_bool& processing_halted)
|
||||||
{
|
{
|
||||||
bool cache_changed = false;
|
bool cache_changed = false;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <span>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -30,9 +31,14 @@ public:
|
|||||||
Yes = 1,
|
Yes = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using ForEachFn = std::function<void(const std::shared_ptr<const GameFile>&)>;
|
||||||
|
using GameAddedToCacheFn = std::function<void(const std::shared_ptr<const GameFile>&)>;
|
||||||
|
using GameRemovedFromCacheFn = std::function<void(const std::string&)>;
|
||||||
|
using GameUpdatedFn = std::function<void(const std::shared_ptr<const GameFile>&)>;
|
||||||
|
|
||||||
GameFileCache();
|
GameFileCache();
|
||||||
|
|
||||||
void ForEach(std::function<void(const std::shared_ptr<const GameFile>&)> f) const;
|
void ForEach(const ForEachFn& f) const;
|
||||||
|
|
||||||
size_t GetSize() const;
|
size_t GetSize() const;
|
||||||
void Clear(DeleteOnDisk delete_on_disk);
|
void Clear(DeleteOnDisk delete_on_disk);
|
||||||
@ -41,12 +47,11 @@ public:
|
|||||||
std::shared_ptr<const GameFile> AddOrGet(const std::string& path, bool* cache_changed);
|
std::shared_ptr<const GameFile> AddOrGet(const std::string& path, bool* cache_changed);
|
||||||
|
|
||||||
// These functions return true if the call modified the cache.
|
// These functions return true if the call modified the cache.
|
||||||
bool Update(const std::vector<std::string>& all_game_paths,
|
bool Update(std::span<const std::string> all_game_paths,
|
||||||
std::function<void(const std::shared_ptr<const GameFile>&)> game_added_to_cache = {},
|
const GameAddedToCacheFn& game_added_to_cache = {},
|
||||||
std::function<void(const std::string&)> game_removed_from_cache = {},
|
const GameRemovedFromCacheFn& game_removed_from_cache = {},
|
||||||
const std::atomic_bool& processing_halted = false);
|
const std::atomic_bool& processing_halted = false);
|
||||||
bool UpdateAdditionalMetadata(
|
bool UpdateAdditionalMetadata(const GameUpdatedFn& game_updated = {},
|
||||||
std::function<void(const std::shared_ptr<const GameFile>&)> game_updated = {},
|
|
||||||
const std::atomic_bool& processing_halted = false);
|
const std::atomic_bool& processing_halted = false);
|
||||||
|
|
||||||
bool Load();
|
bool Load();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user