From cf872d1e0dc968d275d426e9cc988ed66e5d04c8 Mon Sep 17 00:00:00 2001 From: louist103 Date: Sat, 4 Jun 2022 22:10:55 -0400 Subject: [PATCH] cleanups --- libultraship/libultraship/ResourceMgr.cpp | 12 ++++++------ libultraship/libultraship/ResourceMgr.h | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libultraship/libultraship/ResourceMgr.cpp b/libultraship/libultraship/ResourceMgr.cpp index 0033ef442..f3f5cc688 100644 --- a/libultraship/libultraship/ResourceMgr.cpp +++ b/libultraship/libultraship/ResourceMgr.cpp @@ -9,7 +9,7 @@ namespace Ship { - ResourceMgr::ResourceMgr(std::shared_ptr Context, std::string MainPath, std::string PatchesPath) : Context(Context), bIsRunning(false), FileLoadThread(nullptr) { + ResourceMgr::ResourceMgr(std::shared_ptr Context, const std::string& MainPath, const std::string& PatchesPath) : Context(Context), bIsRunning(false), FileLoadThread(nullptr) { OTR = std::make_shared(MainPath, PatchesPath, false); gameVersion = OOT_UNKNOWN; @@ -95,7 +95,7 @@ namespace Ship { //Lock.unlock(); - SPDLOG_DEBUG("Loaded File {} on ResourceMgr thread", ToLoad->path); + SPDLOG_DEBUG("Loaded File {} on ResourceMgr thread", ToLoad->path.c_str()); ToLoad->FileLoadNotifier.notify_all(); } @@ -186,7 +186,7 @@ namespace Ship { gameVersion = newGameVersion; } - std::shared_ptr ResourceMgr::LoadFileAsync(std::string FilePath) { + std::shared_ptr ResourceMgr::LoadFileAsync(const std::string& FilePath) { const std::lock_guard Lock(FileLoadMutex); // File NOT already loaded...? auto fileCacheFind = FileCache.find(FilePath); @@ -204,7 +204,7 @@ namespace Ship { return fileCacheFind->second; } - std::shared_ptr ResourceMgr::LoadFile(std::string FilePath) { + std::shared_ptr ResourceMgr::LoadFile(const std::string& FilePath) { auto ToLoad = LoadFileAsync(FilePath); // Wait for the File to actually be loaded if we are told to block. std::unique_lock Lock(ToLoad->FileLoadMutex); @@ -280,7 +280,7 @@ namespace Ship { } } - std::shared_ptr>> ResourceMgr::CacheDirectoryAsync(std::string SearchMask) { + std::shared_ptr>> ResourceMgr::CacheDirectoryAsync(const std::string& SearchMask) { auto loadedList = std::make_shared>>(); auto fileList = OTR->ListFiles(SearchMask); @@ -299,7 +299,7 @@ namespace Ship { return loadedList; } - std::shared_ptr>> ResourceMgr::CacheDirectory(std::string SearchMask) { + std::shared_ptr>> ResourceMgr::CacheDirectory(const std::string& SearchMask) { auto PromiseList = CacheDirectoryAsync(SearchMask); auto LoadedList = std::make_shared>>(); diff --git a/libultraship/libultraship/ResourceMgr.h b/libultraship/libultraship/ResourceMgr.h index e76d5b521..a880eec47 100644 --- a/libultraship/libultraship/ResourceMgr.h +++ b/libultraship/libultraship/ResourceMgr.h @@ -17,7 +17,7 @@ namespace Ship // It works with the original game's assets because the entire ROM is 64MB and fits into RAM of any semi-modern PC. class ResourceMgr { public: - ResourceMgr(std::shared_ptr Context, std::string MainPath, std::string PatchesPath); + ResourceMgr(std::shared_ptr Context, const std::string& MainPath, const std::string& PatchesPath); ~ResourceMgr(); bool IsRunning(); @@ -32,14 +32,14 @@ namespace Ship uint32_t GetGameVersion(); void SetGameVersion(uint32_t newGameVersion); - std::shared_ptr LoadFileAsync(std::string FilePath); - std::shared_ptr LoadFile(std::string FilePath); + std::shared_ptr LoadFileAsync(const std::string& FilePath); + std::shared_ptr LoadFile(const std::string& FilePath); std::shared_ptr GetCachedFile(const char* FilePath) const; std::shared_ptr LoadResource(const char* FilePath); std::shared_ptr LoadResource(const std::string& FilePath) { return LoadResource(FilePath.c_str()); } std::variant, std::shared_ptr> LoadResourceAsync(const char* FilePath); - std::shared_ptr>> CacheDirectory(std::string SearchMask); - std::shared_ptr>> CacheDirectoryAsync(std::string SearchMask); + std::shared_ptr>> CacheDirectory(const std::string& SearchMask); + std::shared_ptr>> CacheDirectoryAsync(const std::string& SearchMask); std::shared_ptr>> DirtyDirectory(std::string SearchMask); protected: