Open carmineos opened 3 years ago
A possible change could be editing both GetParts and GetReferences to take directly an HashSet
public override void GetParts(HashSet<Tuple<long, IResourceBlock>> blocks)
{
base.GetParts(blocks);
// Add parts to the hashset
}
public override void GetReferences(HashSet<IResourceBlock> blocks)
{
base.GetReferences(blocks);
// Add references to the hashset
}
which would also require the setter of BlockPosition to create a temporary HashSet
public virtual long BlockPosition
{
get
{
return position;
}
set
{
position = value;
var parts = new HashSet<Tuple<long, IResourceBlock>>();
GetParts(parts);
foreach (var part in parts)
{
part.Item2.BlockPosition = value + part.Item1;
}
}
}
Try to reduce allocations when GetReferences and GetParts are invoked.