diff options
author | Joey Hess <joey@kitenet.net> | 2010-10-31 01:51:50 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-10-31 01:51:50 -0400 |
commit | 6a9a9bd5a316f143964574e5ed12eb69b1d17c41 (patch) | |
tree | c48ac6876dc63fb97117c13fc654806a85185722 /Utility.hs | |
parent | 59672d32edd9cc30942a9200670b3e1f817d26aa (diff) |
another memory optimisation
This time memory leaked if lots of UUIDs needed to be pretty-printed, as in
a get or drop of many files. Essentially the same strict read buffering
problem that affected the LocationLog underneath though.
uuidMap really could stand to be cached, as the uuid log is read many times
in this case. But it is a fairly edge case.
Diffstat (limited to 'Utility.hs')
-rw-r--r-- | Utility.hs | 16 |
1 files changed, 0 insertions, 16 deletions
diff --git a/Utility.hs b/Utility.hs index 233825b65..e7b4b510b 100644 --- a/Utility.hs +++ b/Utility.hs @@ -6,7 +6,6 @@ -} module Utility ( - withFileLocked, hGetContentsStrict, parentDir, relPathCwdToDir, @@ -28,21 +27,6 @@ import System.IO.HVFS import System.FilePath import System.Directory -{- Let's just say that Haskell makes reading/writing a file with - - file locking excessively difficult. -} -withFileLocked file mode action = do - -- TODO: find a way to use bracket here - handle <- openFile file mode - lockfd <- handleToFd handle -- closes handle - waitToSetLock lockfd (lockType mode, AbsoluteSeek, 0, 0) - handle' <- fdToHandle lockfd - ret <- action handle' - hClose handle' - return ret - where - lockType ReadMode = ReadLock - lockType _ = WriteLock - {- A version of hgetContents that is not lazy. Ensures file is - all read before it gets closed. -} hGetContentsStrict h = hGetContents h >>= \s -> length s `seq` return s |