diff options
author | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2021-04-06 15:51:38 +0300 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-05-23 18:53:13 -0400 |
commit | d82d38239f232c3970a8641bb6d47d436e3cbc11 (patch) | |
tree | 55b162143144486cddda1b2a2a7ca0b7eb373a1c /ghc/GHCi | |
parent | 82c6a9394b0457e77bc8b03e3594111b51508469 (diff) | |
download | haskell-d82d38239f232c3970a8641bb6d47d436e3cbc11.tar.gz |
Introduce Strict.Maybe, Strict.Pair (#19156)
This patch fixes a space leak related to the use of
Maybe in RealSrcSpan by introducing a strict variant
of Maybe.
In addition to that, it also introduces a strict pair
and uses the newly introduced strict data types in a few
other places (e.g. the lexer/parser state) to reduce
allocations.
Includes a regression test.
Diffstat (limited to 'ghc/GHCi')
-rw-r--r-- | ghc/GHCi/UI.hs | 7 | ||||
-rw-r--r-- | ghc/GHCi/UI/Info.hs | 3 |
2 files changed, 6 insertions, 4 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs index 4e90e930c2..9b520c7e23 100644 --- a/ghc/GHCi/UI.hs +++ b/ghc/GHCi/UI.hs @@ -101,6 +101,7 @@ import GHC.Utils.Panic.Plain import GHC.Utils.Misc import qualified GHC.LanguageExtensions as LangExt import GHC.Data.Bag (unitBag) +import qualified GHC.Data.Strict as Strict -- Haskell Libraries import System.Console.Haskeline as Haskeline @@ -3742,7 +3743,7 @@ stepLocalCmd arg = withSandboxOnly ":steplocal" $ step arg Just loc -> do md <- fromMaybe (panic "stepLocalCmd") <$> getCurrentBreakModule current_toplevel_decl <- enclosingTickSpan md loc - doContinue (`isSubspanOf` RealSrcSpan current_toplevel_decl Nothing) GHC.SingleStep + doContinue (`isSubspanOf` RealSrcSpan current_toplevel_decl Strict.Nothing) GHC.SingleStep stepModuleCmd :: GhciMonad m => String -> m () stepModuleCmd arg = withSandboxOnly ":stepmodule" $ step arg @@ -4094,7 +4095,7 @@ findBreakAndSet md lookupTickTree = do (alreadySet, nm) <- recordBreak $ BreakLocation { breakModule = md - , breakLoc = RealSrcSpan pan Nothing + , breakLoc = RealSrcSpan pan Strict.Nothing , breakTick = tick , onBreakCmd = "" , breakEnabled = True @@ -4156,7 +4157,7 @@ findBreakByCoord mb_file (line, col) arr ticks = arr ! line -- the ticks that span this coordinate - contains = [ tick | tick@(_,pan) <- ticks, RealSrcSpan pan Nothing `spans` (line,col), + contains = [ tick | tick@(_,pan) <- ticks, RealSrcSpan pan Strict.Nothing `spans` (line,col), is_correct_file pan ] is_correct_file pan diff --git a/ghc/GHCi/UI/Info.hs b/ghc/GHCi/UI/Info.hs index db09243967..dcda66e634 100644 --- a/ghc/GHCi/UI/Info.hs +++ b/ghc/GHCi/UI/Info.hs @@ -48,6 +48,7 @@ import GHC.Utils.Outputable import GHC.Types.SrcLoc import GHC.Tc.Utils.Zonk import GHC.Types.Var +import qualified GHC.Data.Strict as Strict -- | Info about a module. This information is generated every time a -- module is loaded. @@ -145,7 +146,7 @@ findNameUses infos span0 string = locToSpans (modinfo,name',span') = stripSurrounding (span' : map toSrcSpan spans) where - toSrcSpan s = RealSrcSpan (spaninfoSrcSpan s) Nothing + toSrcSpan s = RealSrcSpan (spaninfoSrcSpan s) Strict.Nothing spans = filter ((== Just name') . fmap getName . spaninfoVar) (modinfoSpans modinfo) |