summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-02-23 20:25:31 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-02-23 20:25:31 -0400
commit3aab18a4c171b6f812bfe89877401421d293a515 (patch)
treebdf7e96bf2eddffe1409003dbe1985778ee25ceb
parentcab5b78a7d08d8ed3d25751844e6aa43278fccfb (diff)
no streaming
extractTree has to parse the whole input list in order to generate a tree, so convert interface to non-streaming. Some quick memory benchmarks in a repo with 60k files don't look too bad despite not streaming. To stream, without building up a whole tree object, one way would be a new interface: adjustTree :: MonadIO m :: (TreeItem -> m (Maybe TreeItem)) -> Ref -> Repo -> m Sha This would only need to buffer tree objects from the current one down to the root, in order to update trees when a TreeItem is changed. But, while it supports changing items in the tree, and removing items, it does not support adding new items, or moving items from one directory to another.
-rw-r--r--Git/Tree.hs10
1 files changed, 7 insertions, 3 deletions
diff --git a/Git/Tree.hs b/Git/Tree.hs
index c4cbe03f1..f6c445641 100644
--- a/Git/Tree.hs
+++ b/Git/Tree.hs
@@ -5,6 +5,8 @@
- Licensed under the GNU GPL version 3 or higher.
-}
+{-# LANGUAGE BangPatterns #-}
+
module Git.Tree (
Tree(..),
TreeContent(..),
@@ -36,12 +38,14 @@ data TreeContent
deriving (Show)
{- Gets the Tree for a Ref. -}
-getTree :: Ref -> Repo -> IO (Tree, IO Bool)
+getTree :: Ref -> Repo -> IO Tree
getTree r repo = do
-- Pass -t to get the tree object shas, which are normally omitted.
(l, cleanup) <- LsTree.lsTree' [Param "-t"] r repo
- let t = either (\e -> error ("ls-tree parse error:" ++ e)) id (extractTree l)
- return (t, cleanup)
+ let !t = either (\e -> error ("ls-tree parse error:" ++ e)) id
+ (extractTree l)
+ void cleanup
+ return t
{- Assumes the list is ordered, with tree objects coming right before their
- contents. -}