From 105205312b70ff935d7e5513c3585f85ea9fb715 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Fri, 9 Jun 2023 00:07:55 +0300 Subject: [PATCH] rsx: Rewrite the find method to avoid unnecessary allocations --- rpcs3/Emu/RSX/rsx_cache.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/RSX/rsx_cache.h b/rpcs3/Emu/RSX/rsx_cache.h index 7ebb4110e7..51fc4313af 100644 --- a/rpcs3/Emu/RSX/rsx_cache.h +++ b/rpcs3/Emu/RSX/rsx_cache.h @@ -481,13 +481,19 @@ namespace rsx storage_type* find_vertex_range(uptr local_addr, upload_format fmt, u32 data_length) override { - //const auto data_end = local_addr + data_length; + auto found = vertex_ranges.find(local_addr); + if (found == vertex_ranges.end()) + { + return nullptr; + } - for (auto &v : vertex_ranges[local_addr]) + for (auto &v : found->second) { // NOTE: This has to match exactly. Using sized shortcuts such as >= comparison causes artifacting in some applications (UC1) - if (v.buffer_format == fmt && v.data_length == data_length) + if (v.data_length == data_length && v.buffer_format == fmt) + { return &v; + } } return nullptr;