Commit 586d5581 authored by niteria's avatar niteria

Use UniqFM for SigOf

Summary:
The Ord instance for ModuleName is currently implemented in
terms of Uniques causing potential determinism problems.
I plan to change it to use the actual FastStrings and in
preparation for that I'm switching to UniqFM where it's
possible (you need *one* Unique per key, and you can't get
the keys back), so that the performance doesn't suffer.

Test Plan: ./validate

Reviewers: simonmar, austin, ezyang, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2320

GHC Trac Issues: #4012
parent 7de776cf
......@@ -164,6 +164,7 @@ import CmdLineParser
import Constants
import Panic
import Util
import UniqFM
import Maybes
import MonadUtils
import qualified Pretty
......@@ -633,10 +634,10 @@ instance Show SafeHaskellMode where
instance Outputable SafeHaskellMode where
ppr = text . show
type SigOf = Map ModuleName Module
type SigOf = ModuleNameEnv Module
getSigOf :: DynFlags -> ModuleName -> Maybe Module
getSigOf dflags n = Map.lookup n (sigOf dflags)
getSigOf dflags n = lookupUFM (sigOf dflags) n
-- | Contains not only a collection of 'GeneralFlag's but also a plethora of
-- information relating to the compilation of a single file or GHC session
......@@ -1442,7 +1443,7 @@ defaultDynFlags mySettings =
ghcMode = CompManager,
ghcLink = LinkBinary,
hscTarget = defaultHscTarget (sTargetPlatform mySettings),
sigOf = Map.empty,
sigOf = emptyUFM,
verbosity = 0,
optLevel = 0,
debugLevel = 0,
......@@ -1991,7 +1992,7 @@ parseSigOf :: String -> SigOf
parseSigOf str = case filter ((=="").snd) (readP_to_S parse str) of
[(r, "")] -> r
_ -> throwGhcException $ CmdLineError ("Can't parse -sig-of: " ++ str)
where parse = Map.fromList <$> sepBy parseEntry (R.char ',')
where parse = listToUFM <$> sepBy parseEntry (R.char ',')
parseEntry = do
n <- tok $ parseModuleName
-- ToDo: deprecate this 'is' syntax?
......
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