Switch deadeggs to a HashSet

This commit is contained in:
lutepickle 2023-03-19 22:48:04 -07:00
parent 310c03a193
commit f7e3d6c1c4

View file

@ -1364,7 +1364,7 @@ namespace RJW_Menstruation
{
if (eggs.NullOrEmpty()) return false;
List<Egg> deadeggs = new List<Egg>();
HashSet<Egg> deadeggs = new HashSet<Egg>();
bool pregnant = false;
foreach (Egg egg in eggs)
{
@ -1474,12 +1474,7 @@ namespace RJW_Menstruation
return true;
}
else
{
foreach (Egg egg in deadeggs)
{
eggs.Remove(egg);
}
}
eggs.RemoveAll(egg => deadeggs.Contains(egg));
return pregnant;
}
@ -1549,7 +1544,7 @@ namespace RJW_Menstruation
protected void EggDecay()
{
List<Egg> deadeggs = new List<Egg>();
HashSet<Egg> deadeggs = new HashSet<Egg>();
foreach (Egg egg in eggs)
{
egg.position += Configurations.CycleAcceleration;
@ -1560,10 +1555,7 @@ namespace RJW_Menstruation
if (egg.lifespanhrs < 0) deadeggs.Add(egg);
}
}
foreach (Egg egg in deadeggs)
{
eggs.Remove(egg);
}
eggs.RemoveAll(egg => deadeggs.Contains(egg));
}
protected void AddCrampPain()