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.
This commit is contained in:
parent
e266a6ec78
commit
123f823ef7
1 changed files with 7 additions and 3 deletions
10
Git/Tree.hs
10
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. -}
|
||||
|
|
Loading…
Add table
Reference in a new issue