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.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE BangPatterns #-}
|
||||||
|
|
||||||
module Git.LsTree (
|
module Git.LsTree (
|
||||||
TreeItem(..),
|
TreeItem(..),
|
||||||
lsTree,
|
lsTree,
|
||||||
|
@ -68,7 +70,7 @@ lsTreeFiles t fs repo = map parseLsTree <$> pipeNullSplitStrict ps repo
|
||||||
- (The --long format is not currently supported.) -}
|
- (The --long format is not currently supported.) -}
|
||||||
parseLsTree :: String -> TreeItem
|
parseLsTree :: String -> TreeItem
|
||||||
parseLsTree l = TreeItem
|
parseLsTree l = TreeItem
|
||||||
{ mode = fst $ Prelude.head $ readOct m
|
{ mode = smode
|
||||||
, typeobj = t
|
, typeobj = t
|
||||||
, sha = Ref s
|
, sha = Ref s
|
||||||
, file = asTopFilePath $ Git.Filename.decode f
|
, file = asTopFilePath $ Git.Filename.decode f
|
||||||
|
@ -78,6 +80,8 @@ parseLsTree l = TreeItem
|
||||||
-- All fields are fixed, so we can pull them out of
|
-- All fields are fixed, so we can pull them out of
|
||||||
-- specific positions in the line.
|
-- specific positions in the line.
|
||||||
(m, past_m) = splitAt 7 l
|
(m, past_m) = splitAt 7 l
|
||||||
(t, past_t) = splitAt 4 past_m
|
(!t, past_t) = splitAt 4 past_m
|
||||||
(s, past_s) = splitAt shaSize $ Prelude.tail past_t
|
(!s, past_s) = splitAt shaSize $ Prelude.tail past_t
|
||||||
f = Prelude.tail past_s
|
!f = Prelude.tail past_s
|
||||||
|
!smode = fst $ Prelude.head $ readOct m
|
||||||
|
!sfile = asTopFilePath $ Git.Filename.decode f
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue