Skip to content

Commit 30d48ed

Browse files
authored
Fix 2 space leaks (#2774)
* Fix a space leak in hls-graph * Fix leak in ExportsMap and optimize
1 parent 621c2bb commit 30d48ed

File tree

2 files changed

+8
-10
lines changed
  • ghcide/src/Development/IDE/Types
  • hls-graph/src/Development/IDE/Graph/Internal

2 files changed

+8
-10
lines changed

ghcide/src/Development/IDE/Types/Exports.hs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import qualified Data.HashMap.Strict as Map
2222
import Data.HashSet (HashSet)
2323
import qualified Data.HashSet as Set
2424
import Data.Hashable (Hashable)
25-
import Data.List (isSuffixOf)
25+
import Data.List (isSuffixOf, foldl')
2626
import Data.Text (Text, pack)
2727
import Development.IDE.GHC.Compat
2828
import Development.IDE.GHC.Orphans ()
@@ -32,8 +32,8 @@ import HieDb
3232

3333

3434
data ExportsMap = ExportsMap
35-
{ getExportsMap :: HashMap IdentifierText (HashSet IdentInfo)
36-
, getModuleExportsMap :: HashMap ModuleNameText (HashSet IdentInfo)
35+
{ getExportsMap :: !(HashMap IdentifierText (HashSet IdentInfo))
36+
, getModuleExportsMap :: !(HashMap ModuleNameText (HashSet IdentInfo))
3737
}
3838
deriving (Show)
3939

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

136136
updateExportsMapMg :: [ModGuts] -> ExportsMap -> ExportsMap
137-
updateExportsMapMg modGuts old =
138-
old' <> new
137+
updateExportsMapMg modGuts old = old' <> new
139138
where
140139
new = createExportsMapMg modGuts
141140
old' = deleteAll old (Map.keys $ getModuleExportsMap new)
142-
deleteAll = foldr deleteEntriesForModule
143-
141+
deleteAll = foldl' (flip deleteEntriesForModule)
144142

145143
createExportsMapTc :: [TcGblEnv] -> ExportsMap
146144
createExportsMapTc modIface = do

hls-graph/src/Development/IDE/Graph/Internal/Types.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ getDatabaseValues = atomically
120120
. databaseValues
121121

122122
data Status
123-
= Clean Result
123+
= Clean !Result
124124
| Dirty (Maybe Result)
125125
| Running {
126126
runningStep :: !Step,
127127
runningWait :: !(IO ()),
128-
runningResult :: Result,
128+
runningResult :: Result, -- LAZY
129129
runningPrev :: !(Maybe Result)
130130
}
131131

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

151151
data ResultDeps = UnknownDeps | AlwaysRerunDeps ![Key] | ResultDeps ![Key]

0 commit comments

Comments
 (0)