From: Jean Privat Date: Wed, 16 Apr 2014 17:28:13 +0000 (-0400) Subject: rta: do not try to remove things from a set in iteration X-Git-Tag: v0.6.6~101^2~4 X-Git-Url: http://nitlanguage.org rta: do not try to remove things from a set in iteration Instead, register the things to remove then remove them once the iteration is over, Signed-off-by: Jean Privat --- diff --git a/src/rapid_type_analysis.nit b/src/rapid_type_analysis.nit index 4916889..a40ca22 100644 --- a/src/rapid_type_analysis.nit +++ b/src/rapid_type_analysis.nit @@ -164,6 +164,9 @@ class RapidTypeAnalysis # Methods that are still candidate to the try_send private var totry_methods = new HashSet[MMethod] + # Methods that are are no more candidate to the try_send + private var totry_methods_to_remove = new Array[MMethod] + # Methods that are or were candidate to the try_send # Used to ensure that try_send is only used once private var try_methods = new HashSet[MMethod] @@ -330,6 +333,10 @@ class RapidTypeAnalysis for p in totry_methods do try_send(mtype, p) for p in live_super_sends do try_super_send(mtype, p) + # Remove cleared ones + for p in totry_methods_to_remove do totry_methods.remove(p) + totry_methods_to_remove.clear + var bound_mtype = mtype.anchor_to(mainmodule, recv) for cd in bound_mtype.collect_mclassdefs(mainmodule) do @@ -378,7 +385,7 @@ class RapidTypeAnalysis if not live_methoddefs.has(d) then return end #print "full property: {mpropdef.mproperty} for {mpropdef.mproperty.mpropdefs.length} definitions" - totry_methods.remove(mpropdef.mproperty) + totry_methods_to_remove.add(mpropdef.mproperty) end fun add_send(recv: MType, mproperty: MMethod)