From cb8a001cdf8f0cf4dca5bd4c8df07466f006655b Mon Sep 17 00:00:00 2001 From: lutepickle <28810-lutepickle@users.noreply.gitgud.io> Date: Sun, 19 Mar 2023 22:52:39 -0700 Subject: [PATCH] Change removecums to a HashSet --- .../HediffComps/HediffComp_Menstruation.cs | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs index 4020e36..cbf3864 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Menstruation.cs @@ -1037,7 +1037,7 @@ namespace RJW_Menstruation if (TotalCum > Props.maxCumCapacity * Pawn.BodySize) leakfactor = Math.Min(1 + (TotalCum - Props.maxCumCapacity * Pawn.BodySize) / 10, 2f); if (absorber != null && absorber.dirty && !absorber.LeakAfterDirty) leakfactor = 0f; if (Pawn.CurJobDef == xxx.knotted) leakfactor = 0f; - List removecums = new List(); + HashSet removecums = new HashSet(); foreach (Cum cum in cums) { cum.CumEffects(Pawn); @@ -1050,10 +1050,7 @@ namespace RJW_Menstruation } if (cums.Count > 1) MakeCumFilthMixture(totalleak, filthlabels); else if (cums.Count == 1) MakeCumFilth(cums.First(), totalleak); - foreach (Cum cum in removecums) - { - cums.Remove(cum); - } + cums.RemoveAll(cum => removecums.Contains(cum)); cumd = TotalCumPercent - cumd; if (totalleak >= 1.0f) AfterCumOut(); AfterFluidOut(cumd); @@ -1073,7 +1070,7 @@ namespace RJW_Menstruation List filthlabels = new List(); float outcum = 0; float cumd = TotalCumPercent; - List removecums = new List(); + HashSet removecums = new HashSet(); foreach (Cum cum in cums) { float vd = cum.DismishForce(portion); @@ -1086,10 +1083,7 @@ namespace RJW_Menstruation } if (cums.Count > 1) MakeCumFilthMixture(totalleak, filthlabels); else if (cums.Count == 1) MakeCumFilth(cums.First(), totalleak); - foreach (Cum cum in removecums) - { - cums.Remove(cum); - } + cums.RemoveAll(cum => removecums.Contains(cum)); cumd = TotalCumPercent - cumd; AfterFluidOut(cumd); return outcum; @@ -1107,7 +1101,7 @@ namespace RJW_Menstruation Color color = GetCumMixtureColor; float totalleak = 0; List cumlabels = new List(); - List removecums = new List(); + HashSet removecums = new HashSet(); bool pure = true; foreach (Cum cum in cums) { @@ -1118,10 +1112,7 @@ namespace RJW_Menstruation if (cum.ShouldRemove()) removecums.Add(cum); if (cum.notcum) pure = false; } - foreach (Cum cum in removecums) - { - cums.Remove(cum); - } + cums.RemoveAll(cum => removecums.Contains(cum)); return new CumMixture(Pawn, totalleak, cumlabels, color, mixtureDef, pure); }