From 4bee333d847783582f94b5212cb7641e0936dc4c Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 21 Jul 2023 19:22:14 -0400 Subject: general: reduce use of dynamic_cast --- src/android/app/src/main/jni/native.cpp | 2 +- src/core/core.cpp | 8 ++++++++ src/core/core.h | 3 +++ src/yuzu/game_list_worker.cpp | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 8bc6a4a04..c23b2f19e 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -449,7 +449,7 @@ private: loader->ReadTitle(entry.title); loader->ReadIcon(entry.icon); if (loader->GetFileType() == Loader::FileType::NRO) { - jauto loader_nro = dynamic_cast(loader.get()); + jauto loader_nro = reinterpret_cast(loader.get()); entry.isHomebrew = loader_nro->IsHomebrew(); } else { entry.isHomebrew = false; diff --git a/src/core/core.cpp b/src/core/core.cpp index 9e3eb3795..48233d7c8 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -880,6 +880,14 @@ const FileSys::ContentProvider& System::GetContentProvider() const { return *impl->content_provider; } +FileSys::ContentProviderUnion& System::GetContentProviderUnion() { + return *impl->content_provider; +} + +const FileSys::ContentProviderUnion& System::GetContentProviderUnion() const { + return *impl->content_provider; +} + Service::FileSystem::FileSystemController& System::GetFileSystemController() { return impl->fs_controller; } diff --git a/src/core/core.h b/src/core/core.h index 14b2f7785..c70ea1965 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -381,6 +381,9 @@ public: [[nodiscard]] FileSys::ContentProvider& GetContentProvider(); [[nodiscard]] const FileSys::ContentProvider& GetContentProvider() const; + [[nodiscard]] FileSys::ContentProviderUnion& GetContentProviderUnion(); + [[nodiscard]] const FileSys::ContentProviderUnion& GetContentProviderUnion() const; + [[nodiscard]] Service::FileSystem::FileSystemController& GetFileSystemController(); [[nodiscard]] const Service::FileSystem::FileSystemController& GetFileSystemController() const; diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp index 63326968b..5c910c9e0 100644 --- a/src/yuzu/game_list_worker.cpp +++ b/src/yuzu/game_list_worker.cpp @@ -235,7 +235,7 @@ GameListWorker::~GameListWorker() = default; void GameListWorker::AddTitlesToGameList(GameListDir* parent_dir) { using namespace FileSys; - const auto& cache = dynamic_cast(system.GetContentProvider()); + const auto& cache = system.GetContentProviderUnion(); auto installed_games = cache.ListEntriesFilterOrigin(std::nullopt, TitleType::Application, ContentRecordType::Program); -- cgit v1.2.3