Commit eb76d16d by Zachary Snow

faster package item nesting conversion

parent 48f84a9e
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
module Convert.NestPI (convert) where module Convert.NestPI (convert) where
import Control.Monad.Writer import Control.Monad.Writer
import Data.List (isPrefixOf)
import Data.List.Unique (complex) import Data.List.Unique (complex)
import qualified Data.Set as Set import qualified Data.Set as Set
...@@ -56,10 +55,8 @@ convertDescription pis (orig @ Part{}) = ...@@ -56,10 +55,8 @@ convertDescription pis (orig @ Part{}) =
, collectTypesM $ collectNestedTypesM collectTypenamesM , collectTypesM $ collectNestedTypesM collectTypenamesM
, collectExprsM $ collectNestedExprsM collectIdentsM , collectExprsM $ collectNestedExprsM collectIdentsM
] ]
neededPIs = Set.difference neededPIs = Set.difference (Set.union usedPIs imports) existingPIs
(Set.union usedPIs $ imports = Set.fromList $ map fst $ filter (isImport . snd) pis
Set.filter (isPrefixOf "import ") $ Set.fromList $ map fst pis)
existingPIs
uniq l = l' where (l', _, _) = complex l uniq l = l' where (l', _, _) = complex l
newItems = uniq $ map MIPackageItem $ map snd $ newItems = uniq $ map MIPackageItem $ map snd $
filter (\(x, _) -> Set.member x neededPIs) pis filter (\(x, _) -> Set.member x neededPIs) pis
...@@ -108,3 +105,7 @@ piName (Decl (CommentDecl _)) = Nothing ...@@ -108,3 +105,7 @@ piName (Decl (CommentDecl _)) = Nothing
piName (Import x y) = Just $ show $ Import x y piName (Import x y) = Just $ show $ Import x y
piName (Export _) = Nothing piName (Export _) = Nothing
piName (Directive _) = Nothing piName (Directive _) = Nothing
isImport :: PackageItem -> Bool
isImport Import{} = True
isImport _ = False
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment