From f6cc00c7e53ea5bc6fa19177bdb98ddcf25440d0 Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Mon, 19 Jan 2026 15:21:43 +1300 Subject: State now uses a Vector instead of a Map --- src/kompsos.adb | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'src/kompsos.adb') diff --git a/src/kompsos.adb b/src/kompsos.adb index 4a34b1b..ae7848d 100644 --- a/src/kompsos.adb +++ b/src/kompsos.adb @@ -209,6 +209,25 @@ package body Kompsos is + -- States -- + + function Lookup + (This : in State; + Key : in Variable; + Value : out Term'Class) + return Boolean is + begin + for Bind of This.Actual loop + if Bind.Key = Key then + Value := Term'Class (Bind.Elem); + return True; + end if; + end loop; + return False; + end Lookup; + + + -- Goal Graphs -- package Graph_Convert is new System.Address_To_Access_Conversions (Graph_Component); @@ -550,11 +569,15 @@ package body Kompsos is when Null_Term | Atom_Term => return This; when Var_Term => - if Subst.Actual.Contains (This.Var) then - return Subst.Actual.Element (This.Var).Resolve (Subst); - else - return This; - end if; + declare + Bound_Term : Term; + begin + if Lookup (Subst, This.Var, Bound_Term) then + return Bound_Term.Resolve (Subst); + else + return This; + end if; + end; when Pair_Term => return T (This.Left.Resolve (Subst), This.Right.Resolve (Subst)); end case; @@ -568,7 +591,7 @@ package body Kompsos is if Subst.Actual.Is_Empty then return Empty_Term; else - return Subst.Actual.First_Element.Resolve (Subst); + return Subst.Actual.First_Element.Elem.Resolve (Subst); end if; end Resolve_First; -- cgit