From: Joey Hess Date: Tue, 19 Dec 2023 01:35:00 +0000 (-0400) Subject: refactor X-Git-Tag: archive/raspbian/10.20250416-2+rpi1~1^2~29^2~96 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c64db46b7f9429f889f8d77e0f6c31a126b1c653;p=git-annex.git refactor --- diff --git a/Utility/Matcher.hs b/Utility/Matcher.hs index c5eec539fb..38864e05fd 100644 --- a/Utility/Matcher.hs +++ b/Utility/Matcher.hs @@ -105,16 +105,8 @@ pruneMatcher :: (op -> Bool) -> Matcher op -> Matcher op pruneMatcher f = fst . go where go MAny = (MAny, False) - go (MAnd a b) = case (go a, go b) of - ((_, True), (_, True)) -> (MAny, True) - ((a', False), (b', False)) -> (MAnd a' b', False) - ((_, True), (b', False)) -> (b', False) - ((a', False), (_, True)) -> (a', False) - go (MOr a b) = case (go a, go b) of - ((_, True), (_, True)) -> (MAny, True) - ((a', False), (b', False)) -> (MOr a' b', False) - ((_, True), (b', False)) -> (b', False) - ((a', False), (_, True)) -> (a', False) + go (MAnd a b) = go2 a b MAnd + go (MOr a b) = go2 a b MOr go (MNot a) = case go a of (_, True) -> (MAny, True) (a', False) -> (MNot a', False) @@ -122,6 +114,12 @@ pruneMatcher f = fst . go | f op = (MAny, True) | otherwise = (MOp op, False) + go2 a b g = case (go a, go b) of + ((_, True), (_, True)) -> (MAny, True) + ((a', False), (b', False)) -> (g a' b', False) + ((_, True), (b', False)) -> (b', False) + ((a', False), (_, True)) -> (a', False) + data TokenGroup op = One (Token op) | Group [TokenGroup op] deriving (Show, Eq)