diff --git a/Ryujinx.Graphics/ResourcePool.cs b/Ryujinx.Graphics/ResourcePool.cs index 44e475b67a..43c7a90d50 100644 --- a/Ryujinx.Graphics/ResourcePool.cs +++ b/Ryujinx.Graphics/ResourcePool.cs @@ -62,7 +62,7 @@ namespace Ryujinx.Graphics public TValue CreateOrRecycle(TKey Params) { - LinkedList Siblings = GetOrAddEntry(Params); + LinkedList Siblings = GetOrAddSiblings(Params); foreach (TValue RecycledValue in Siblings) { @@ -119,19 +119,24 @@ namespace Ryujinx.Graphics } } - private LinkedList GetOrAddEntry(TKey Params) + private LinkedList GetOrAddSiblings(TKey Params) { - foreach ((TKey MyParams, LinkedList Resources) Tuple in Entries) + LinkedListNode<(TKey, LinkedList)> Node = Entries.First; + + while (Node != null) { - if (Tuple.MyParams.IsCompatible(Params)) + (TKey Params, LinkedList Resources) Tuple = Node.Value; + + if (Tuple.Params.IsCompatible(Params)) { - //Move accessed siblings to the top of the list, for faster access in the future - Entries.Remove(Tuple); + Entries.Remove(Node); Entries.AddFirst(Tuple); return Tuple.Resources; } + + Node = Node.Next; } LinkedList Siblings = new LinkedList();