diff options
author | bunnei <bunneidev@gmail.com> | 2018-07-21 20:38:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-21 20:38:52 +0200 |
commit | 0f20fa5a1e179bdad07fe1e0e58243d1927274fd (patch) | |
tree | 1e36cf5bf5bb44a6c77087dfd7161b72739dbf3e /src/core/file_sys/partition_filesystem.cpp | |
parent | Merge pull request #750 from lioncash/ctx (diff) | |
parent | vfs_real: Remove redundant copying of std::vector instances in GetFiles() and GetSubdirectories() (diff) | |
download | yuzu-0f20fa5a1e179bdad07fe1e0e58243d1927274fd.tar yuzu-0f20fa5a1e179bdad07fe1e0e58243d1927274fd.tar.gz yuzu-0f20fa5a1e179bdad07fe1e0e58243d1927274fd.tar.bz2 yuzu-0f20fa5a1e179bdad07fe1e0e58243d1927274fd.tar.lz yuzu-0f20fa5a1e179bdad07fe1e0e58243d1927274fd.tar.xz yuzu-0f20fa5a1e179bdad07fe1e0e58243d1927274fd.tar.zst yuzu-0f20fa5a1e179bdad07fe1e0e58243d1927274fd.zip |
Diffstat (limited to 'src/core/file_sys/partition_filesystem.cpp')
-rw-r--r-- | src/core/file_sys/partition_filesystem.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/core/file_sys/partition_filesystem.cpp b/src/core/file_sys/partition_filesystem.cpp index 7ccca1089..8d2bd9f6b 100644 --- a/src/core/file_sys/partition_filesystem.cpp +++ b/src/core/file_sys/partition_filesystem.cpp @@ -2,7 +2,12 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <algorithm> +#include <cstddef> +#include <cstring> +#include <iterator> #include <utility> + #include "common/file_util.h" #include "common/logging/log.h" #include "core/file_sys/partition_filesystem.h" @@ -99,14 +104,15 @@ void PartitionFilesystem::PrintDebugInfo() const { } bool PartitionFilesystem::ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) { - auto iter = std::find(pfs_files.begin(), pfs_files.end(), file); + const auto iter = std::find(pfs_files.begin(), pfs_files.end(), file); if (iter == pfs_files.end()) return false; - pfs_files[iter - pfs_files.begin()] = pfs_files.back(); + const std::ptrdiff_t offset = std::distance(pfs_files.begin(), iter); + pfs_files[offset] = pfs_files.back(); pfs_files.pop_back(); - pfs_dirs.emplace_back(dir); + pfs_dirs.emplace_back(std::move(dir)); return true; } |