From d82d38239f232c3970a8641bb6d47d436e3cbc11 Mon Sep 17 00:00:00 2001 From: Vladislav Zavialov Date: Tue, 6 Apr 2021 15:51:38 +0300 Subject: 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. --- compiler/GHC/Parser/Header.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'compiler/GHC/Parser/Header.hs') diff --git a/compiler/GHC/Parser/Header.hs b/compiler/GHC/Parser/Header.hs index 7a60830d34..52a98d86dc 100644 --- a/compiler/GHC/Parser/Header.hs +++ b/compiler/GHC/Parser/Header.hs @@ -55,6 +55,7 @@ import GHC.Data.StringBuffer import GHC.Data.Maybe import GHC.Data.Bag (Bag, isEmptyBag ) import GHC.Data.FastString +import qualified GHC.Data.Strict as Strict import Control.Monad import System.IO @@ -347,7 +348,7 @@ toArgs starting_loc orig_str advance_src_loc_many = foldl' advanceSrcLoc locate :: RealSrcLoc -> RealSrcLoc -> a -> Located a - locate begin end x = L (RealSrcSpan (mkRealSrcSpan begin end) Nothing) x + locate begin end x = L (RealSrcSpan (mkRealSrcSpan begin end) Strict.Nothing) x toArgs' :: RealSrcLoc -> String -> Either String [Located String] -- Remove outer quotes: -- cgit v1.2.1