mirror of
https://github.com/yuzu-emu/yuzu-android
synced 2024-11-22 22:03:44 +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
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <set>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include "core/file_sys/vfs_layered.h"
|
#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> LayeredVfsDirectory::GetFiles() const {
|
||||||
std::vector<VirtualFile> out;
|
std::vector<VirtualFile> out;
|
||||||
|
std::set<std::string, std::less<>> out_names;
|
||||||
|
|
||||||
for (const auto& layer : dirs) {
|
for (const auto& layer : dirs) {
|
||||||
for (const auto& file : layer->GetFiles()) {
|
for (const auto& file : layer->GetFiles()) {
|
||||||
if (std::find_if(out.begin(), out.end(), [&file](const VirtualFile& comp) {
|
auto file_name = file->GetName();
|
||||||
return comp->GetName() == file->GetName();
|
if (!out_names.contains(file_name)) {
|
||||||
}) == out.end()) {
|
out_names.emplace(std::move(file_name));
|
||||||
out.push_back(file);
|
out.push_back(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue