add a small cache of the most recently accessed item from the git-annex branch

This will speed up typical cases like git-annex get, which currently
has to read the location log once, then read it a second time in order to
add a line to it. Since these reads now involve more than just reading
in a file, it seemed good to add a cache layer.

Only the most recent thing needs to be cached, because git-annex has
good locality; it operates on one file at a time, and only cares
about one item from the branch per file.
This commit is contained in:
Joey Hess 2011-06-22 14:18:49 -04:00
parent 1cca8b4edb
commit 78a325b093
3 changed files with 38 additions and 6 deletions

16
Types/Branch.hs Normal file
View file

@ -0,0 +1,16 @@
{- git-annex branch data types
-
- Copyright 2011 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Types.Branch where
data BranchCache = BranchCache {
cachedFile :: Maybe FilePath,
cachedContent :: String
}
emptyBranchCache :: BranchCache
emptyBranchCache = BranchCache Nothing ""