From 138d5dc64adf8e19a2d5b3d5bc6de3ee2099388c Mon Sep 17 00:00:00 2001 From: riperiperi Date: Sun, 16 Apr 2023 18:57:01 +0100 Subject: [PATCH] Vulkan: HashTableSlim lookup optimization (#4688) --- Ryujinx.Graphics.Vulkan/HashTableSlim.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Ryujinx.Graphics.Vulkan/HashTableSlim.cs b/Ryujinx.Graphics.Vulkan/HashTableSlim.cs index 2dde2aeb2a..e4ad395878 100644 --- a/Ryujinx.Graphics.Vulkan/HashTableSlim.cs +++ b/Ryujinx.Graphics.Vulkan/HashTableSlim.cs @@ -15,6 +15,7 @@ namespace Ryujinx.Graphics.Vulkan private struct Entry { + public int Hash; public K Key; public V Value; } @@ -59,6 +60,7 @@ namespace Ryujinx.Graphics.Vulkan { var entry = new Entry() { + Hash = key.GetHashCode(), Key = key, Value = value }; @@ -91,12 +93,11 @@ namespace Ryujinx.Graphics.Vulkan var bucket = _hashTable[hashCode & TotalBucketsMask]; if (bucket != null) { - for (int i = 0; i < bucket.Length; i++) { ref var entry = ref bucket[i]; - if (entry.Key.Equals(ref key)) + if (entry.Hash == hashCode && entry.Key.Equals(ref key)) { value = entry.Value; return true;