1
0
forked from MeloNX/MeloNX

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 GitHub
parent ed3f843992
commit a26122d1a9

View File

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