Skip to content

Commit aa272f4

Browse files
author
Laurent
committed
Replace HashSet with Vector
1 parent 4d998cc commit aa272f4

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

core/package.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ library:
1616
- template-haskell
1717
- text
1818
- unordered-containers
19+
- vector
1920
- wl-pprint-text
2021

2122
tests:

core/src/Language/Avaleryar/Semantics.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@ import Control.DeepSeq (NFData)
7070
import Control.Monad.Except
7171
import Control.Monad.State
7272
import Data.Foldable
73-
import qualified Data.HashSet as HashSet
7473
import Data.Map (Map)
7574
import qualified Data.Map as Map
7675
import Data.Maybe
7776
import Data.String
77+
import Data.Vector (Vector)
78+
import qualified Data.Vector as Vector
7879
import Data.Text (Text, pack)
7980
import Data.Void (vacuous)
8081
import GHC.Clock (getMonotonicTime)
@@ -282,7 +283,7 @@ compilePred rules =
282283
if all isFact rules
283284
then
284285
-- We precompute the set
285-
let setOfVals = HashSet.fromList $ fmap (mapMaybe termVal . litTerms . ruleLit) rules
286+
let setOfVals = Vector.fromList $ fmap (mapMaybe termVal . litTerms . ruleLit) rules
286287
in \arg@(Lit _ qas) -> do
287288
qas <- traverse subst qas
288289
let f term (allVals, vals) = case term of
@@ -293,7 +294,7 @@ compilePred rules =
293294
-- In that case, if the values of qas are in the set, the predicate succeeds.
294295
-- Otherwise, it fails.
295296
if allVals
296-
then guard (HashSet.member vals setOfVals)
297+
then guard (Vector.elem vals setOfVals)
297298
-- If qas aren't all values, we can't use the set and must fallback to the default behavior.
298299
-- This is because in this case the variables will be unified with the values, so it's not just
299300
-- a guard.

0 commit comments

Comments
 (0)