Skip to content

Commit

Permalink
Fix 2 space leaks (haskell#2774)
Browse files Browse the repository at this point in the history
* Fix a space leak in hls-graph

* Fix leak in ExportsMap and optimize
  • Loading branch information
pepeiborra authored and July541 committed Mar 29, 2022
1 parent 4824357 commit 209061f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
12 changes: 5 additions & 7 deletions ghcide/src/Development/IDE/Types/Exports.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import qualified Data.HashMap.Strict as Map
import Data.HashSet (HashSet)
import qualified Data.HashSet as Set
import Data.Hashable (Hashable)
import Data.List (isSuffixOf)
import Data.List (isSuffixOf, foldl')
import Data.Text (Text, pack)
import Development.IDE.GHC.Compat
import Development.IDE.GHC.Orphans ()
Expand All @@ -32,8 +32,8 @@ import HieDb


data ExportsMap = ExportsMap
{ getExportsMap :: HashMap IdentifierText (HashSet IdentInfo)
, getModuleExportsMap :: HashMap ModuleNameText (HashSet IdentInfo)
{ getExportsMap :: !(HashMap IdentifierText (HashSet IdentInfo))
, getModuleExportsMap :: !(HashMap ModuleNameText (HashSet IdentInfo))
}
deriving (Show)

Expand Down Expand Up @@ -134,13 +134,11 @@ createExportsMapMg modGuts = do
concatMap (fmap (second Set.fromList) . unpackAvail getModuleName) (mg_exports mi)

updateExportsMapMg :: [ModGuts] -> ExportsMap -> ExportsMap
updateExportsMapMg modGuts old =
old' <> new
updateExportsMapMg modGuts old = old' <> new
where
new = createExportsMapMg modGuts
old' = deleteAll old (Map.keys $ getModuleExportsMap new)
deleteAll = foldr deleteEntriesForModule

deleteAll = foldl' (flip deleteEntriesForModule)

createExportsMapTc :: [TcGblEnv] -> ExportsMap
createExportsMapTc modIface = do
Expand Down
6 changes: 3 additions & 3 deletions hls-graph/src/Development/IDE/Graph/Internal/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ getDatabaseValues = atomically
. databaseValues

data Status
= Clean Result
= Clean !Result
| Dirty (Maybe Result)
| Running {
runningStep :: !Step,
runningWait :: !(IO ()),
runningResult :: Result,
runningResult :: Result, -- LAZY
runningPrev :: !(Maybe Result)
}

Expand All @@ -145,7 +145,7 @@ data Result = Result {
resultVisited :: !Step, -- ^ the step when it was last looked up
resultDeps :: !ResultDeps,
resultExecution :: !Seconds, -- ^ How long it took, last time it ran
resultData :: BS.ByteString
resultData :: !BS.ByteString
}

data ResultDeps = UnknownDeps | AlwaysRerunDeps ![Key] | ResultDeps ![Key]
Expand Down

0 comments on commit 209061f

Please sign in to comment.