diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-02-23 23:08:41 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-02-23 23:08:41 -0400 |
commit | 65c51156f44a8e68eb8d3658894c2d5efa871f30 (patch) | |
tree | 54a6fbcc2bd74b56f4eee0868e7bc689ab969a59 /Git/LsTree.hs | |
parent | 9e881b648f1837eb28599825c37f33ddec8841ce (diff) |
parse strictly
This reduces memory use, because it avoids thunks that buffer parts of the
ls-tree output that are not needed.
Diffstat (limited to 'Git/LsTree.hs')
-rw-r--r-- | Git/LsTree.hs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Git/LsTree.hs b/Git/LsTree.hs index f4b6a781e..cc3b45dda 100644 --- a/Git/LsTree.hs +++ b/Git/LsTree.hs @@ -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 |