diff options
| -rw-r--r-- | src/core/file_sys/romfs.cpp | 3 | ||||
| -rw-r--r-- | src/core/file_sys/vfs_vector.cpp | 19 | ||||
| -rw-r--r-- | src/core/file_sys/vfs_vector.h | 4 |
3 files changed, 2 insertions, 24 deletions
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 @@ | |||
| 9 | #include "core/file_sys/fsmitm_romfsbuild.h" | 9 | #include "core/file_sys/fsmitm_romfsbuild.h" |
| 10 | #include "core/file_sys/romfs.h" | 10 | #include "core/file_sys/romfs.h" |
| 11 | #include "core/file_sys/vfs.h" | 11 | #include "core/file_sys/vfs.h" |
| 12 | #include "core/file_sys/vfs_cached.h" | ||
| 12 | #include "core/file_sys/vfs_concat.h" | 13 | #include "core/file_sys/vfs_concat.h" |
| 13 | #include "core/file_sys/vfs_offset.h" | 14 | #include "core/file_sys/vfs_offset.h" |
| 14 | #include "core/file_sys/vfs_vector.h" | 15 | #include "core/file_sys/vfs_vector.h" |
| @@ -132,7 +133,7 @@ VirtualDir ExtractRomFS(VirtualFile file, RomFSExtractionType type) { | |||
| 132 | out = out->GetSubdirectories().front(); | 133 | out = out->GetSubdirectories().front(); |
| 133 | } | 134 | } |
| 134 | 135 | ||
| 135 | return out; | 136 | return std::make_shared<CachedVfsDirectory>(out); |
| 136 | } | 137 | } |
| 137 | 138 | ||
| 138 | VirtualFile CreateRomFS(VirtualDir dir, VirtualDir ext) { | 139 | 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<VirtualFile> files_, | |||
| 67 | 67 | ||
| 68 | VectorVfsDirectory::~VectorVfsDirectory() = default; | 68 | VectorVfsDirectory::~VectorVfsDirectory() = default; |
| 69 | 69 | ||
| 70 | VirtualFile VectorVfsDirectory::GetFile(std::string_view file_name) const { | ||
| 71 | if (!optimized_file_index_built) { | ||
| 72 | optimized_file_index.clear(); | ||
| 73 | for (size_t i = 0; i < files.size(); i++) { | ||
| 74 | optimized_file_index.emplace(files[i]->GetName(), i); | ||
| 75 | } | ||
| 76 | optimized_file_index_built = true; | ||
| 77 | } | ||
| 78 | |||
| 79 | const auto it = optimized_file_index.find(file_name); | ||
| 80 | if (it != optimized_file_index.end()) { | ||
| 81 | return files[it->second]; | ||
| 82 | } | ||
| 83 | |||
| 84 | return nullptr; | ||
| 85 | } | ||
| 86 | |||
| 87 | std::vector<VirtualFile> VectorVfsDirectory::GetFiles() const { | 70 | std::vector<VirtualFile> VectorVfsDirectory::GetFiles() const { |
| 88 | return files; | 71 | return files; |
| 89 | } | 72 | } |
| @@ -124,7 +107,6 @@ bool VectorVfsDirectory::DeleteSubdirectory(std::string_view subdir_name) { | |||
| 124 | } | 107 | } |
| 125 | 108 | ||
| 126 | bool VectorVfsDirectory::DeleteFile(std::string_view file_name) { | 109 | bool VectorVfsDirectory::DeleteFile(std::string_view file_name) { |
| 127 | optimized_file_index_built = false; | ||
| 128 | return FindAndRemoveVectorElement(files, file_name); | 110 | return FindAndRemoveVectorElement(files, file_name); |
| 129 | } | 111 | } |
| 130 | 112 | ||
| @@ -142,7 +124,6 @@ VirtualFile VectorVfsDirectory::CreateFile(std::string_view file_name) { | |||
| 142 | } | 124 | } |
| 143 | 125 | ||
| 144 | void VectorVfsDirectory::AddFile(VirtualFile file) { | 126 | void VectorVfsDirectory::AddFile(VirtualFile file) { |
| 145 | optimized_file_index_built = false; | ||
| 146 | files.push_back(std::move(file)); | 127 | files.push_back(std::move(file)); |
| 147 | } | 128 | } |
| 148 | 129 | ||
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: | |||
| 105 | VirtualDir parent = nullptr); | 105 | VirtualDir parent = nullptr); |
| 106 | ~VectorVfsDirectory() override; | 106 | ~VectorVfsDirectory() override; |
| 107 | 107 | ||
| 108 | VirtualFile GetFile(std::string_view file_name) const override; | ||
| 109 | std::vector<VirtualFile> GetFiles() const override; | 108 | std::vector<VirtualFile> GetFiles() const override; |
| 110 | std::vector<VirtualDir> GetSubdirectories() const override; | 109 | std::vector<VirtualDir> GetSubdirectories() const override; |
| 111 | bool IsWritable() const override; | 110 | bool IsWritable() const override; |
| @@ -127,9 +126,6 @@ private: | |||
| 127 | 126 | ||
| 128 | VirtualDir parent; | 127 | VirtualDir parent; |
| 129 | std::string name; | 128 | std::string name; |
| 130 | |||
| 131 | mutable std::map<std::string, size_t, std::less<>> optimized_file_index; | ||
| 132 | mutable bool optimized_file_index_built{}; | ||
| 133 | }; | 129 | }; |
| 134 | 130 | ||
| 135 | } // namespace FileSys | 131 | } // namespace FileSys |