java-topology/defects/azahar-0001/patch/azahar-0001.patch

27 lines
1.2 KiB
Diff

# UNDF: UNDF-2026-000001061
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -1,6 +1,7 @@
// Copyright Citra Emulator Project / Azahar Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
+#include <unordered_set>
// ... (other includes unchanged)
@@ -3728,8 +3728,10 @@ void Module::Interface::CommitImportTitlesImpl(Kernel::HLERequestContext& ctx,
auto& title_id_buf = rp.PopMappedBuffer();
std::vector<u64> title_ids(title_id_buf.GetSize() / sizeof(u64));
title_id_buf.Read(title_ids.data(), 0, title_id_buf.GetSize());
+ // Build a hash set for O(1) membership test instead of O(T) per lookup.
+ const std::unordered_set<u64> title_id_set(title_ids.begin(), title_ids.end());
+
for (auto& key_value : am->import_content_contexts) {
- if (std::find(title_ids.begin(), title_ids.end(), key_value.first) != title_ids.end() &&
+ if (title_id_set.count(key_value.first) &&
key_value.second.state == ImportTitleContextState::WAITING_FOR_COMMIT) {
key_value.second.state = ImportTitleContextState::NEEDS_CLEANUP;
}
}