diff options
author | Joey Hess <joey@kitenet.net> | 2012-01-29 22:55:06 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-01-29 22:55:06 -0400 |
commit | a964012fc36d22e4554dd12e3594579fb3190501 (patch) | |
tree | 31c3a5ea4fb78088b4981eb4185737353ec1ff3e /Annex.hs | |
parent | 0609e102396083afa6380f8b67a69fa849235d16 (diff) |
switch to the strict state monad
I had not realized what a memory leak the lazy state monad could be,
although I have not seen much evidence of actual leaking in git-annex.
However, if running git-annex on a great many files, this could matter.
The additional Utility.State.changeState adds even more strictness,
avoiding a problem I saw in github-backup where repeatedly modifying
state built up a huge pile of thunks.
Diffstat (limited to 'Annex.hs')
-rw-r--r-- | Annex.hs | 15 |
1 files changed, 2 insertions, 13 deletions
@@ -26,7 +26,7 @@ module Annex ( fromRepo, ) where -import Control.Monad.State +import Control.Monad.State.Strict import Control.Monad.Trans.Control (StM, MonadBaseControl, liftBaseWith, restoreM) import Control.Monad.Base (liftBase, MonadBase) import System.Posix.Types (Fd) @@ -41,6 +41,7 @@ import qualified Types.Remote import Types.Crypto import Types.BranchState import Types.TrustLevel +import Utility.State import qualified Utility.Matcher import qualified Data.Map as M @@ -125,18 +126,6 @@ run s a = runStateT (runAnnex a) s eval :: AnnexState -> Annex a -> IO a eval s a = evalStateT (runAnnex a) s -{- Gets a value from the internal state, selected by the passed value - - constructor. -} -getState :: (AnnexState -> a) -> Annex a -getState = gets - -{- Applies a state mutation function to change the internal state. - - - - Example: changeState $ \s -> s { output = QuietOutput } - -} -changeState :: (AnnexState -> AnnexState) -> Annex () -changeState = modify - {- Sets a flag to True -} setFlag :: String -> Annex () setFlag flag = changeState $ \s -> |