[tools] 01/01: Group bp commands more efficiently

Joachim Breitner nomeata at moszumanska.debian.org
Fri Jul 21 22:43:09 UTC 2017


This is an automated email from the git hooks/post-receive script.

nomeata pushed a commit to branch master
in repository tools.

commit 94c4d408ee70353aa0e7f58ea56124cfbb67204f
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Fri Jul 21 18:42:00 2017 -0400

    Group bp commands more efficiently
---
 binNMUs.hs | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/binNMUs.hs b/binNMUs.hs
index fd0e4b5..f968678 100644
--- a/binNMUs.hs
+++ b/binNMUs.hs
@@ -173,19 +173,22 @@ alignAt d lines = unlines (map expands rows)
 presentBinNMUs :: Conf -> [CBinNMU] -> IO ()
 presentBinNMUs conf cBinNMUs = do
     forM_ (ordGroupBy fst cBinNMUs) $ \(s, cBinNMUs) -> do
-        let groupedBinNMUs = sortBy (compare `on` (^. _1)) $
-                             groupNMUs conf $
-                             map snd cBinNMUs
+        let binNMUs = map snd cBinNMUs
 
         unless (ignoreStatus s) $ do
         putCLn $ statusHeader s
         putStr $ alignAt " . "
-            [ (if actStatus s then "" else "# ") ++ formatNMU (distribution conf) nmu
-            | nmu <- groupedBinNMUs ]
+            [ (if actStatus s then "" else "# ") ++
+              formatNMU (distribution conf) nmu
+            | nmu <- sortBy (compare `on` (^. _1)) $
+                     groupNMUs conf binNMUs
+            ]
         when (actStatus s) $ for_ (mbPriority conf) $ \prio -> do
             putStr $ alignAt " . "
                 [ formatBP prio (distribution conf) nmu
-                | nmu <- groupedBinNMUs ]
+                | nmu <- sortBy (compare `on` (^. _1)) $
+                         groupBPs conf binNMUs
+                ]
             putStrLn ""
 
 
@@ -203,12 +206,19 @@ groupNMUs conf =
   where
     gbp = groupPkgs conf
 
-formatBP :: Int -> String -> ([(SourceName, Version)], [Arch], [Reason]) -> String
-formatBP prio dist (ss, as, d) =
+groupBPs :: (Ord a, Ord b) => Conf -> [(a, b, c)] -> [(a, [b])]
+groupBPs conf =
+    groupEqual .
+    map (\(a,b,c) -> (a,b))
+  where
+    gbp = groupPkgs conf
+
+formatBP :: Int -> String -> ((SourceName, Version), [Arch]) -> String
+formatBP prio dist (s, as) =
     printf "bp %d %s . %s . %s"
         prio
-        (intercalate " " $ map (uncurry (printf "%s_%s")) ss)
-        (intercalate " " $ nub as)
+        (uncurry (printf "%s_%s") s :: String)
+        (unwords (nub as))
         dist
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-haskell/tools.git



More information about the Pkg-haskell-commits mailing list