Skip to content

Commit

Permalink
screened 2024-08-11 11:17:29+00:00
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Franksen authored and Ben Franksen committed Aug 11, 2024
1 parent dbf18bf commit fa59457
Show file tree
Hide file tree
Showing 7 changed files with 383 additions and 437 deletions.
9 changes: 1 addition & 8 deletions src/Darcs/Util/ByteString.hs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ import qualified Codec.Compression.Zlib.Internal as ZI
import Darcs.Util.Encoding ( decode, encode, decodeUtf8, encodeUtf8 )
import Darcs.Util.Global ( addCRCWarning )

#if mingw32_HOST_OS
#else
import System.IO.MMap( mmapFileByteString )
#endif
import System.Mem( performGC )

------------------------------------------------------------------------
Expand Down Expand Up @@ -277,7 +274,7 @@ gzReadStdin = do
-- fed to (uncurry mmapFileByteString) or similar.
type FileSegment = (FilePath, Maybe (Int64, Int))

-- | Read in a FileSegment into a Lazy ByteString. Implemented using mmap.
-- | Read in a FileSegment into a Lazy ByteString.
readSegment :: FileSegment -> IO BL.ByteString
readSegment (f,range) = do
bs <- tryToRead
Expand Down Expand Up @@ -310,17 +307,13 @@ readSegment (f,range) = do
-- is modified.

mmapFilePS :: FilePath -> IO B.ByteString
#if mingw32_HOST_OS
mmapFilePS = B.readFile
#else
mmapFilePS f =
mmapFileByteString f Nothing
`catchIOError` (\_ -> do
size <- getFileSize f
if size == 0
then return B.empty
else performGC >> mmapFileByteString f Nothing)
#endif

-- -------------------------------------------------------------------------
-- fromPS2Hex
Expand Down
Loading

0 comments on commit fa59457

Please sign in to comment.