@@ -38,8 +38,6 @@ import Data.Function
38
38
import Data.Bifunctor
39
39
import Data.Containers.ListUtils
40
40
41
- import Data.Sequence (Seq (.. ))
42
- import qualified Data.Sequence as Seq
43
41
import qualified Data.Foldable as F
44
42
import qualified Data.IntMap.Strict as IM
45
43
import qualified Data.Set as S
@@ -85,7 +83,7 @@ add uncanon_e egr =
85
83
-- to the e-class parents the new e-node and its e-class id
86
84
--
87
85
-- And add new e-class to existing e-classes
88
- new_parents = ((new_eclass_id, new_en) :<| )
86
+ new_parents = (S. insert (new_eclass_id, new_en))
89
87
new_classes = IM. insert new_eclass_id new_eclass $
90
88
foldr (IM. adjust ((_parents %~ new_parents)))
91
89
(classes egr)
@@ -154,7 +152,7 @@ merge a b egr0 =
154
152
155
153
-- Leader is the class with more parents
156
154
(leader, leader_class, sub, sub_class) =
157
- if Seq. length (class_a^. _parents) < Seq. length (class_b^. _parents)
155
+ if S. size (class_a^. _parents) < S. size (class_b^. _parents)
158
156
then (b', class_b, a', class_a) -- b is leader
159
157
else (a', class_a, b', class_b) -- a is leader
160
158
@@ -181,7 +179,7 @@ merge a b egr0 =
181
179
-- class whose data is different from the merged must be put on the
182
180
-- analysisWorklist
183
181
new_analysis_worklist =
184
- F. toList (
182
+ (
185
183
(if new_data /= (sub_class^. _data)
186
184
then sub_class^. _parents
187
185
else mempty ) <>
@@ -222,7 +220,7 @@ rebuild (EGraph uf cls mm wl awl) =
222
220
let
223
221
emptiedEgr = EGraph uf cls mm mempty mempty
224
222
wl' = nubOrd $ bimap (`find` emptiedEgr) (`canonicalize` emptiedEgr) <$> wl
225
- awl' = nubOrd $ bimap (`find` emptiedEgr) (`canonicalize` emptiedEgr) <$> awl
223
+ awl' = S. map ( bimap (`find` emptiedEgr) (`canonicalize` emptiedEgr)) awl
226
224
egr' = foldr repair emptiedEgr wl'
227
225
egr'' = foldr repairAnal egr' awl'
228
226
in
@@ -258,7 +256,7 @@ repairAnal (repair_id, node) egr =
258
256
if c^. _data /= new_data
259
257
-- Merge result is different from original class data, update class
260
258
-- with new_data
261
- then egr { analysisWorklist = F. toList (c^. _parents) <> analysisWorklist egr
259
+ then egr { analysisWorklist = (c^. _parents) <> analysisWorklist egr
262
260
}
263
261
& _class repair_id. _data .~ new_data
264
262
& modifyA repair_id
0 commit comments