mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-22 01:22:51 -06:00
Extract the previous optimization to its own function
This commit is contained in:
@@ -129,9 +129,17 @@ isInherited :: MInclude -> Ident -> Bool
|
|||||||
isInherited c =
|
isInherited c =
|
||||||
case c of
|
case c of
|
||||||
MIAll -> const True
|
MIAll -> const True
|
||||||
MIOnly is -> let is' = Set.fromList is in (`Set.member` is')
|
MIOnly is -> elemOrd is
|
||||||
MIExcept is -> let is' = Set.fromList is in (`Set.notMember` is')
|
MIExcept is -> not . elemOrd is
|
||||||
|
|
||||||
|
-- | Faster version of `elem`, using a `Set`.
|
||||||
|
-- Make sure you give this the first argument _outside_ of the inner loop
|
||||||
|
--
|
||||||
|
-- Example:
|
||||||
|
-- > myIntersection xs ys = filter (elemOrd xs) ys
|
||||||
|
elemOrd :: Ord a => [a] -> a -> Bool
|
||||||
|
elemOrd list = (`Set.member` set)
|
||||||
|
where set = Set.fromList list
|
||||||
|
|
||||||
inheritAll :: ModuleName -> (ModuleName,MInclude)
|
inheritAll :: ModuleName -> (ModuleName,MInclude)
|
||||||
inheritAll i = (i,MIAll)
|
inheritAll i = (i,MIAll)
|
||||||
|
|||||||
Reference in New Issue
Block a user