mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-26 19:28:54 -06:00
Merge pull request #147 from anka-213/extend-performance-issue
Improve performance with long extend-lists
This commit is contained in:
@@ -78,6 +78,7 @@ import PGF.Internal (FId, FunId, SeqId, LIndex, Sequence, BindType(..))
|
|||||||
import Data.Array.IArray(Array)
|
import Data.Array.IArray(Array)
|
||||||
import Data.Array.Unboxed(UArray)
|
import Data.Array.Unboxed(UArray)
|
||||||
import qualified Data.Map as Map
|
import qualified Data.Map as Map
|
||||||
|
import qualified Data.Set as Set
|
||||||
import GF.Text.Pretty
|
import GF.Text.Pretty
|
||||||
|
|
||||||
|
|
||||||
@@ -125,10 +126,20 @@ extends :: ModuleInfo -> [ModuleName]
|
|||||||
extends = map fst . mextend
|
extends = map fst . mextend
|
||||||
|
|
||||||
isInherited :: MInclude -> Ident -> Bool
|
isInherited :: MInclude -> Ident -> Bool
|
||||||
isInherited c i = case c of
|
isInherited c =
|
||||||
MIAll -> True
|
case c of
|
||||||
MIOnly is -> elem i is
|
MIAll -> const True
|
||||||
MIExcept is -> notElem i is
|
MIOnly is -> elemOrd 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