speed up currentView when not in a view
Avoid reading the view log when the branch is clearly not a view branch.
This commit is contained in:
parent
1fe6cd3c0d
commit
02259d2a55
1 changed files with 9 additions and 9 deletions
18
Logs/View.hs
18
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
|
||||
|
|
Loading…
Add table
Reference in a new issue