mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-10-01 12:30:00 +02:00
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:
parent
095ad923ad
commit
58207685c0
1 changed files with 10 additions and 2 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue