forked from GitHub/gf-core
Use a Set in isInherited to speed up long extend lists
Now the time is O(log(n)*m) instead of O(n*m) where n is the number of items in the extend list e.g. abstract FromWordNet = WordNet [ a_couple_Card, a_la_carte_Adv, a_la_mode_Adv, a_little_Card, ... ];
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.Unboxed(UArray)
|
||||
import qualified Data.Map as Map
|
||||
import qualified Data.Set as Set
|
||||
import GF.Text.Pretty
|
||||
|
||||
|
||||
@@ -125,10 +126,12 @@ extends :: ModuleInfo -> [ModuleName]
|
||||
extends = map fst . mextend
|
||||
|
||||
isInherited :: MInclude -> Ident -> Bool
|
||||
isInherited c i = case c of
|
||||
MIAll -> True
|
||||
MIOnly is -> elem i is
|
||||
MIExcept is -> notElem i is
|
||||
isInherited c =
|
||||
case c of
|
||||
MIAll -> const True
|
||||
MIOnly is -> let is' = Set.fromList is in (`Set.member` is')
|
||||
MIExcept is -> let is' = Set.fromList is in (`Set.notMember` is')
|
||||
|
||||
|
||||
inheritAll :: ModuleName -> (ModuleName,MInclude)
|
||||
inheritAll i = (i,MIAll)
|
||||
|
||||
Reference in New Issue
Block a user