Perform bounds checking before list indexer to avoid frequent exceptions (#4438)

* Perform bounds checking before list indexer to avoid frequent ArgumentOutOfRangeExceptions

* do a single compare after casting id and .Count to uint
This commit is contained in:
jhorv 2023-02-25 05:26:39 -05:00 committed by Matt Heins
parent ff3c5f54c6
commit e7ad67da44

View file

@ -80,8 +80,16 @@ namespace Ryujinx.Graphics.Vulkan
try
{
value = _list[id];
return value != null;
if ((uint)id < (uint)_list.Count)
{
value = _list[id];
return value != null;
}
else
{
value = null;
return false;
}
}
catch (ArgumentOutOfRangeException)
{