fix: Cleans up FindItems and removes allocations (#1516)
This commit is contained in:
parent
a4cabe2fa4
commit
d77dac9516
17 changed files with 105 additions and 127 deletions
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Network;
|
||||
using Server.Prompts;
|
||||
|
|
@ -74,9 +75,7 @@ public partial class Key : Item
|
|||
return;
|
||||
}
|
||||
|
||||
var items = cont.FindItemsByType(new[] { typeof(Key), typeof(KeyRing) });
|
||||
|
||||
foreach (var item in items)
|
||||
foreach (var item in cont.EnumerateItems())
|
||||
{
|
||||
if (item is Key key)
|
||||
{
|
||||
|
|
@ -85,10 +84,8 @@ public partial class Key : Item
|
|||
key.Delete();
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (item is KeyRing keyRing)
|
||||
{
|
||||
var keyRing = (KeyRing)item;
|
||||
|
||||
keyRing.RemoveKey(keyValue);
|
||||
}
|
||||
}
|
||||
|
|
@ -101,9 +98,7 @@ public partial class Key : Item
|
|||
return false;
|
||||
}
|
||||
|
||||
var items = cont.FindItemsByType(new[] { typeof(Key), typeof(KeyRing) });
|
||||
|
||||
foreach (var item in items)
|
||||
foreach (var item in cont.EnumerateItems())
|
||||
{
|
||||
if (item is Key key)
|
||||
{
|
||||
|
|
@ -112,10 +107,8 @@ public partial class Key : Item
|
|||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (item is KeyRing keyRing)
|
||||
{
|
||||
var keyRing = (KeyRing)item;
|
||||
|
||||
if (keyRing.ContainsKey(keyValue))
|
||||
{
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue