parse strictly
This reduces memory use, because it avoids thunks that buffer parts of the ls-tree output that are not needed.
This commit is contained in:
parent
e5dd91b189
commit
804aeca5d2
1 changed files with 8 additions and 4 deletions
|
@ -5,6 +5,8 @@
|
|||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
{-# LANGUAGE BangPatterns #-}
|
||||
|
||||
module Git.LsTree (
|
||||
TreeItem(..),
|
||||
lsTree,
|
||||
|
@ -68,7 +70,7 @@ lsTreeFiles t fs repo = map parseLsTree <$> pipeNullSplitStrict ps repo
|
|||
- (The --long format is not currently supported.) -}
|
||||
parseLsTree :: String -> TreeItem
|
||||
parseLsTree l = TreeItem
|
||||
{ mode = fst $ Prelude.head $ readOct m
|
||||
{ mode = smode
|
||||
, typeobj = t
|
||||
, sha = Ref s
|
||||
, file = asTopFilePath $ Git.Filename.decode f
|
||||
|
@ -78,6 +80,8 @@ parseLsTree l = TreeItem
|
|||
-- All fields are fixed, so we can pull them out of
|
||||
-- specific positions in the line.
|
||||
(m, past_m) = splitAt 7 l
|
||||
(t, past_t) = splitAt 4 past_m
|
||||
(s, past_s) = splitAt shaSize $ Prelude.tail past_t
|
||||
f = Prelude.tail past_s
|
||||
(!t, past_t) = splitAt 4 past_m
|
||||
(!s, past_s) = splitAt shaSize $ Prelude.tail past_t
|
||||
!f = Prelude.tail past_s
|
||||
!smode = fst $ Prelude.head $ readOct m
|
||||
!sfile = asTopFilePath $ Git.Filename.decode f
|
||||
|
|
Loading…
Add table
Reference in a new issue