diff options
| author | Jedidiah Barber <contact@jedbarber.id.au> | 2026-01-17 00:12:45 +1300 |
|---|---|---|
| committer | Jedidiah Barber <contact@jedbarber.id.au> | 2026-01-17 00:12:45 +1300 |
| commit | aa31ebe381d555725cdae2abafa93bac976f1c7e (patch) | |
| tree | 3f434726e6719fd3b07e01aa16262b132a19e978 /src/kompsos-collector.adb | |
| parent | 616f41d15009b1133cbdc14bace6ab84f1325921 (diff) | |
Recurse fixed, caching functions consolidated
Diffstat (limited to 'src/kompsos-collector.adb')
| -rw-r--r-- | src/kompsos-collector.adb | 52 |
1 files changed, 19 insertions, 33 deletions
diff --git a/src/kompsos-collector.adb b/src/kompsos-collector.adb index 792c2b2..e8314ff 100644 --- a/src/kompsos-collector.adb +++ b/src/kompsos-collector.adb @@ -381,6 +381,11 @@ package body Kompsos.Collector is when Recurse_Node => if not Book.Contains (Ptr) then Book.Insert (Ptr, (Kind => Recurse_Data, others => <>)); + if Ptr.Rec_Goal.Actual = null then + Book (Ptr).Rec_Gone := True; + elsif not Cache_Memo.Contains (Ptr.Rec_Goal.Actual) then + Cache_Memo.Insert (Ptr.Rec_Goal.Actual, State_Vectors.Empty_Vector); + end if; end if; if Book (Ptr).Rec_Gone then return False; @@ -396,44 +401,18 @@ package body Kompsos.Collector is return False; else Book (Ptr).Rec_Next := 1; + Book (Ptr).Rec_Cache := False; end if; end loop; + if Book (Ptr).Rec_Cache and Ptr.Rec_Goal.Actual.Counter = 1 then + Cache_Memo (Ptr.Rec_Goal.Actual).Append (Result); + end if; Book (Ptr).Rec_Next := Book.Element (Ptr).Rec_Next + 1; return True; end case; end Do_Get_Next; - function Cached - (Ptr : in Goal_Component_Access; - Index : in Long_Positive; - Result : out State) - return Boolean is - begin - if Cache_Memo.Contains (Ptr) and then Index <= Cache_Memo (Ptr).Last_Index then - Result := Cache_Memo (Ptr) (Index); - return True; - else - return False; - end if; - end Cached; - - - procedure Cache_This - (Ptr : in Goal_Component_Access; - Index : in Long_Positive; - Result : in State) is - begin - if Ptr.Counter > 1 and Ptr.Kind /= Static_Node then - if not Cache_Memo.Contains (Ptr) then - Cache_Memo.Insert (Ptr, State_Vectors.Empty_Vector); - end if; - pragma Assert (Index = Cache_Memo (Ptr).Last_Index + 1); - Cache_Memo (Ptr).Append (Result); - end if; - end Cache_This; - - function Get_Next (Ptr : in Constant_Goal_Access; Base : in State; @@ -443,12 +422,19 @@ package body Kompsos.Collector is begin if Ptr = null or else Ptr.Actual = null then return False; - elsif Cached (Ptr.Actual, Index, Result) then + elsif Cache_Memo.Contains (Ptr.Actual) and then + Index <= Cache_Memo (Ptr.Actual).Last_Index + then + Result := Cache_Memo (Ptr.Actual) (Index); return True; else return Found : constant Boolean := Do_Get_Next (Ptr.Actual, Base, Index, Result) do - if Found then - Cache_This (Ptr.Actual, Index, Result); + if Found and Ptr.Actual.Counter > 1 and Ptr.Actual.Kind /= Static_Node then + if not Cache_Memo.Contains (Ptr.Actual) then + Cache_Memo.Insert (Ptr.Actual, State_Vectors.Empty_Vector); + end if; + pragma Assert (Index = Cache_Memo (Ptr.Actual).Last_Index + 1); + Cache_Memo (Ptr.Actual).Append (Result); end if; end return; end if; |
