Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Commit

Permalink
Making setCache strict in it's first argument instead
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Jun 21, 2019
1 parent 032d7d7 commit b7fb445
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 1 addition & 3 deletions hie-plugin-api/Haskell/Ide/Engine/ModuleCache.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
Expand Down Expand Up @@ -54,8 +53,7 @@ import Haskell.Ide.Engine.PluginsIdeMonads
modifyCache :: (HasGhcModuleCache m) => (GhcModuleCache -> GhcModuleCache) -> m ()
modifyCache f = do
mc <- getModuleCache
let !cached = f mc -- Avoid a space leak by forcing the cache calculation
setModuleCache cached
setModuleCache (f mc)

-- ---------------------------------------------------------------------
-- | Runs an IdeM action with the given Cradle
Expand Down
3 changes: 2 additions & 1 deletion hie-plugin-api/Haskell/Ide/Engine/PluginsIdeMonads.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveAnyClass #-}
Expand Down Expand Up @@ -499,7 +500,7 @@ instance HasGhcModuleCache IdeM where
tvar <- lift ask
state <- liftIO $ readTVarIO tvar
return (moduleCache state)
setModuleCache mc = do
setModuleCache !mc = do
tvar <- lift ask
liftIO $ atomically $ modifyTVar' tvar (\st -> st { moduleCache = mc })

Expand Down

0 comments on commit b7fb445

Please sign in to comment.