summaryrefslogtreecommitdiffstats
path: root/src/core/file_sys
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2023-05-07 22:33:35 +0200
committerLiam <byteslice@airmail.cc>2023-05-08 01:03:41 +0200
commitd100de27ee77fc98e1f3fa3dc6d2db0999da0a1a (patch)
treec2764ab9a2b1096d58e8735170bbb3882169cdca /src/core/file_sys
parentvfs_vector: avoid n^2 lookup in layeredfs building (diff)
downloadyuzu-d100de27ee77fc98e1f3fa3dc6d2db0999da0a1a.tar
yuzu-d100de27ee77fc98e1f3fa3dc6d2db0999da0a1a.tar.gz
yuzu-d100de27ee77fc98e1f3fa3dc6d2db0999da0a1a.tar.bz2
yuzu-d100de27ee77fc98e1f3fa3dc6d2db0999da0a1a.tar.lz
yuzu-d100de27ee77fc98e1f3fa3dc6d2db0999da0a1a.tar.xz
yuzu-d100de27ee77fc98e1f3fa3dc6d2db0999da0a1a.tar.zst
yuzu-d100de27ee77fc98e1f3fa3dc6d2db0999da0a1a.zip
Diffstat (limited to 'src/core/file_sys')
-rw-r--r--src/core/file_sys/vfs_layered.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/core/file_sys/vfs_layered.cpp b/src/core/file_sys/vfs_layered.cpp
index da05dd395..3e6426afc 100644
--- a/src/core/file_sys/vfs_layered.cpp
+++ b/src/core/file_sys/vfs_layered.cpp
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm>
+#include <set>
#include <utility>
#include "core/file_sys/vfs_layered.h"
@@ -58,11 +59,13 @@ std::string LayeredVfsDirectory::GetFullPath() const {
std::vector<VirtualFile> LayeredVfsDirectory::GetFiles() const {
std::vector<VirtualFile> out;
+ std::set<std::string, std::less<>> out_names;
+
for (const auto& layer : dirs) {
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()) {
+ auto file_name = file->GetName();
+ if (!out_names.contains(file_name)) {
+ out_names.emplace(std::move(file_name));
out.push_back(file);
}
}