diff options
author | Zach Hilman <zachhilman@gmail.com> | 2018-09-24 03:50:16 +0200 |
---|---|---|
committer | Zach Hilman <zachhilman@gmail.com> | 2018-09-24 03:50:20 +0200 |
commit | b3c2ec362bbbdd89da9c0aa84b425717f5e3d351 (patch) | |
tree | d3f4e621532f1f280f94bac4e6d071707aabbd35 /src/core/file_sys/vfs_layered.cpp | |
parent | qt: Add UI elements for LayeredFS and related tools (diff) | |
download | yuzu-b3c2ec362bbbdd89da9c0aa84b425717f5e3d351.tar yuzu-b3c2ec362bbbdd89da9c0aa84b425717f5e3d351.tar.gz yuzu-b3c2ec362bbbdd89da9c0aa84b425717f5e3d351.tar.bz2 yuzu-b3c2ec362bbbdd89da9c0aa84b425717f5e3d351.tar.lz yuzu-b3c2ec362bbbdd89da9c0aa84b425717f5e3d351.tar.xz yuzu-b3c2ec362bbbdd89da9c0aa84b425717f5e3d351.tar.zst yuzu-b3c2ec362bbbdd89da9c0aa84b425717f5e3d351.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/file_sys/vfs_layered.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/core/file_sys/vfs_layered.cpp b/src/core/file_sys/vfs_layered.cpp index 802f49384..45563d7ae 100644 --- a/src/core/file_sys/vfs_layered.cpp +++ b/src/core/file_sys/vfs_layered.cpp @@ -20,10 +20,11 @@ VirtualDir LayerDirectories(std::vector<VirtualDir> dirs, std::string name) { LayeredVfsDirectory::LayeredVfsDirectory(std::vector<VirtualDir> dirs, std::string name) : dirs(std::move(dirs)), name(std::move(name)) {} +LayeredVfsDirectory::~LayeredVfsDirectory() = default; + std::shared_ptr<VfsFile> LayeredVfsDirectory::GetFileRelative(std::string_view path) const { - VirtualFile file; for (const auto& layer : dirs) { - file = layer->GetFileRelative(path); + const auto file = layer->GetFileRelative(path); if (file != nullptr) return file; } @@ -35,12 +36,12 @@ std::shared_ptr<VfsDirectory> LayeredVfsDirectory::GetDirectoryRelative( std::string_view path) const { std::vector<VirtualDir> out; for (const auto& layer : dirs) { - const auto dir = layer->GetDirectoryRelative(path); + auto dir = layer->GetDirectoryRelative(path); if (dir != nullptr) - out.push_back(dir); + out.push_back(std::move(dir)); } - return LayerDirectories(out); + return LayerDirectories(std::move(out)); } std::shared_ptr<VfsFile> LayeredVfsDirectory::GetFile(std::string_view name) const { @@ -61,8 +62,9 @@ std::vector<std::shared_ptr<VfsFile>> LayeredVfsDirectory::GetFiles() const { for (const auto& file : layer->GetFiles()) { if (std::find_if(out.begin(), out.end(), [&file](const VirtualFile& comp) { return comp->GetName() == file->GetName(); - }) == out.end()) + }) == out.end()) { out.push_back(file); + } } } @@ -79,6 +81,7 @@ std::vector<std::shared_ptr<VfsDirectory>> LayeredVfsDirectory::GetSubdirectorie } std::vector<VirtualDir> out; + out.reserve(names.size()); for (const auto& subdir : names) out.push_back(GetSubdirectory(subdir)); |