From 6e23c84669d4d6a2cf9ed2ee5cfc0332c6d738db Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 3 Jun 2023 08:56:59 -0400 Subject: romfs: use vfs_cached for romfs output --- src/core/file_sys/romfs.cpp | 3 ++- src/core/file_sys/vfs_vector.cpp | 19 ------------------- src/core/file_sys/vfs_vector.h | 4 ---- 3 files changed, 2 insertions(+), 24 deletions(-) (limited to 'src/core/file_sys') diff --git a/src/core/file_sys/romfs.cpp b/src/core/file_sys/romfs.cpp index fb5683a6b..614da2130 100644 --- a/src/core/file_sys/romfs.cpp +++ b/src/core/file_sys/romfs.cpp @@ -9,6 +9,7 @@ #include "core/file_sys/fsmitm_romfsbuild.h" #include "core/file_sys/romfs.h" #include "core/file_sys/vfs.h" +#include "core/file_sys/vfs_cached.h" #include "core/file_sys/vfs_concat.h" #include "core/file_sys/vfs_offset.h" #include "core/file_sys/vfs_vector.h" @@ -132,7 +133,7 @@ VirtualDir ExtractRomFS(VirtualFile file, RomFSExtractionType type) { out = out->GetSubdirectories().front(); } - return out; + return std::make_shared(out); } VirtualFile CreateRomFS(VirtualDir dir, VirtualDir ext) { diff --git a/src/core/file_sys/vfs_vector.cpp b/src/core/file_sys/vfs_vector.cpp index af1df4c51..251d9d7c9 100644 --- a/src/core/file_sys/vfs_vector.cpp +++ b/src/core/file_sys/vfs_vector.cpp @@ -67,23 +67,6 @@ VectorVfsDirectory::VectorVfsDirectory(std::vector files_, VectorVfsDirectory::~VectorVfsDirectory() = default; -VirtualFile VectorVfsDirectory::GetFile(std::string_view file_name) const { - if (!optimized_file_index_built) { - optimized_file_index.clear(); - for (size_t i = 0; i < files.size(); i++) { - optimized_file_index.emplace(files[i]->GetName(), i); - } - optimized_file_index_built = true; - } - - const auto it = optimized_file_index.find(file_name); - if (it != optimized_file_index.end()) { - return files[it->second]; - } - - return nullptr; -} - std::vector VectorVfsDirectory::GetFiles() const { return files; } @@ -124,7 +107,6 @@ bool VectorVfsDirectory::DeleteSubdirectory(std::string_view subdir_name) { } bool VectorVfsDirectory::DeleteFile(std::string_view file_name) { - optimized_file_index_built = false; return FindAndRemoveVectorElement(files, file_name); } @@ -142,7 +124,6 @@ VirtualFile VectorVfsDirectory::CreateFile(std::string_view file_name) { } void VectorVfsDirectory::AddFile(VirtualFile file) { - optimized_file_index_built = false; files.push_back(std::move(file)); } diff --git a/src/core/file_sys/vfs_vector.h b/src/core/file_sys/vfs_vector.h index c9955755b..bfedb6e42 100644 --- a/src/core/file_sys/vfs_vector.h +++ b/src/core/file_sys/vfs_vector.h @@ -105,7 +105,6 @@ public: VirtualDir parent = nullptr); ~VectorVfsDirectory() override; - VirtualFile GetFile(std::string_view file_name) const override; std::vector GetFiles() const override; std::vector GetSubdirectories() const override; bool IsWritable() const override; @@ -127,9 +126,6 @@ private: VirtualDir parent; std::string name; - - mutable std::map> optimized_file_index; - mutable bool optimized_file_index_built{}; }; } // namespace FileSys -- cgit v1.2.3