fix: Fixes container enumeration not recycling pooled arrays (#2341)
### Summary Updates all calls to container.EnumerateItems() to properly dispose of the underlying PooledRefQueue so that we are properly recycling pooled arrays.
This commit is contained in:
parent
1780edf0be
commit
c494fb4cc3
15 changed files with 388 additions and 365 deletions
|
|
@ -201,7 +201,8 @@ public partial class SalvageBag : Bag
|
|||
var salvaged = 0;
|
||||
var notSalvaged = 0;
|
||||
|
||||
foreach (var item in EnumerateItems())
|
||||
using var queue = EnumerateItems();
|
||||
foreach (var item in queue)
|
||||
{
|
||||
if (item?.Deleted != false)
|
||||
{
|
||||
|
|
@ -250,31 +251,37 @@ public partial class SalvageBag : Bag
|
|||
var salvaged = 0;
|
||||
var notSalvaged = 0;
|
||||
|
||||
foreach (var item in EnumerateItems())
|
||||
using (var queue = EnumerateItems())
|
||||
{
|
||||
if (item is not IScissorable scissorable)
|
||||
foreach (var item in queue)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (item is not IScissorable scissorable)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Scissors.CanScissor(from, scissorable) && scissorable.Scissor(from, scissors))
|
||||
{
|
||||
++salvaged;
|
||||
}
|
||||
else
|
||||
{
|
||||
++notSalvaged;
|
||||
if (Scissors.CanScissor(from, scissorable) && scissorable.Scissor(from, scissors))
|
||||
{
|
||||
++salvaged;
|
||||
}
|
||||
else
|
||||
{
|
||||
++notSalvaged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Salvaged: ~1_COUNT~/~2_NUM~ tailored items
|
||||
from.SendLocalizedMessage(1079974, $"{salvaged}\t{salvaged + notSalvaged}");
|
||||
|
||||
foreach (var item in EnumerateItems())
|
||||
using (var queue = EnumerateItems())
|
||||
{
|
||||
if (item.InTypeList(_clothTypes))
|
||||
foreach (var item in queue)
|
||||
{
|
||||
from.AddToBackpack(item);
|
||||
if (item.InTypeList(_clothTypes))
|
||||
{
|
||||
from.AddToBackpack(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,8 @@ public partial class Key : Item
|
|||
return;
|
||||
}
|
||||
|
||||
foreach (var item in cont.EnumerateItems())
|
||||
using var queue = cont.EnumerateItems();
|
||||
foreach (var item in queue)
|
||||
{
|
||||
if (item is Key key)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -85,7 +85,8 @@ public abstract partial class BasePotion : Item, ICraftable, ICommodity
|
|||
return 1;
|
||||
}
|
||||
|
||||
foreach (var keg in pack.EnumerateItemsByType<PotionKeg>())
|
||||
using var queue = pack.EnumerateItemsByType<PotionKeg>();
|
||||
foreach (var keg in queue)
|
||||
{
|
||||
if (keg.Held is <= 0 or >= 100)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue