fix: Eliminates List allocations in various places. (#2158)

This commit is contained in:
Kamron Batman 2025-11-16 18:33:53 -08:00 • committed by GitHub
parent 6f64cddd0b
commit 4836bff5eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 263 additions and 200 deletions

View file

@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using ModernUO.Serialization;
using Server.Collections;
using Server.Multis;
namespace Server.Items;
@ -102,15 +102,15 @@ public partial class StrongBox : BaseContainer, IChoppable
public Container ConvertToStandardContainer()
{
var metalBox = new MetalBox();
var subItems = new List<Item>(Items);
using var subItems = PooledRefList<Item>.Create(Items.Count);
subItems.AddRange(Items);
foreach (var subItem in subItems)
for (var i = 0; i < subItems.Count; i++)
{
metalBox.AddItem(subItem);
metalBox.AddItem(subItems[i]);
}
Delete();
return metalBox;
}
}