diff options
author | Joey Hess <joey@kitenet.net> | 2014-02-19 12:52:47 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-02-19 12:52:47 -0400 |
commit | 8d0b3f09a9effc71f729d5b820076c642b605eb4 (patch) | |
tree | bf46f214a285de8dde9cdb5eef130ef8c51a950e /Logs | |
parent | b3872e5df8256f25911e0859c474342003b63522 (diff) |
speed up currentView when not in a view
Avoid reading the view log when the branch is clearly not a view branch.
Diffstat (limited to 'Logs')
-rw-r--r-- | Logs/View.hs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Logs/View.hs b/Logs/View.hs index 47ce7c4c1..2a26cfa17 100644 --- a/Logs/View.hs +++ b/Logs/View.hs @@ -50,14 +50,14 @@ recentViews = do {- Gets the currently checked out view, if there is one. -} currentView :: Annex (Maybe View) -currentView = do - vs <- recentViews - maybe Nothing (go vs) <$> inRepo Git.Branch.current +currentView = go =<< inRepo Git.Branch.current where - go [] _ = Nothing - go (v:vs) b - | branchView v == b = Just v - | otherwise = go vs b + go (Just b) | branchViewPrefix `isPrefixOf` fromRef b = + headMaybe . filter (\v -> branchView v == b) <$> recentViews + go _ = return Nothing + +branchViewPrefix :: String +branchViewPrefix = "refs/heads/views" {- Generates a git branch name for a View. - @@ -66,8 +66,8 @@ currentView = do -} branchView :: View -> Git.Branch branchView view - | null name = Git.Ref "refs/heads/views" - | otherwise = Git.Ref $ "refs/heads/views/" ++ name + | null name = Git.Ref branchViewPrefix + | otherwise = Git.Ref $ branchViewPrefix ++ "/" ++ name where name = intercalate ";" $ map branchcomp (viewComponents view) branchcomp c |