mirror of
https://github.com/yuzu-emu/yuzu-mainline
synced 2024-11-24 03:43:58 +00:00
vfs_layered: avoid n^2 lookup in layeredfs building
This commit is contained in:
parent
5792a72c29
commit
d100de27ee
1 changed files with 6 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue