Commit 2a8e2dc9 authored by Iustin Pop's avatar Iustin Pop
Browse files

Fix some lint warnings in htools code



hlint gives more suggestions, but some make the code (IMHO) harder to
read.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent d5072e4c
...@@ -515,10 +515,7 @@ checkMove nodes_idx disk_moves ini_tbl victims = ...@@ -515,10 +515,7 @@ checkMove nodes_idx disk_moves ini_tbl victims =
tables = parMap rwhnf (checkInstanceMove nodes_idx disk_moves ini_tbl) tables = parMap rwhnf (checkInstanceMove nodes_idx disk_moves ini_tbl)
victims victims
-- iterate over all instances, computing the best move -- iterate over all instances, computing the best move
best_tbl = best_tbl = foldl' compareTables ini_tbl tables
foldl'
(\ step_tbl new_tbl -> compareTables step_tbl new_tbl)
ini_tbl tables
Table _ _ _ best_plc = best_tbl Table _ _ _ best_plc = best_tbl
in if length best_plc == length ini_plc in if length best_plc == length ini_plc
then ini_tbl -- no advancement then ini_tbl -- no advancement
...@@ -694,7 +691,7 @@ sortMGResults :: Group.List ...@@ -694,7 +691,7 @@ sortMGResults :: Group.List
-> [(Gdx, AllocSolution)] -> [(Gdx, AllocSolution)]
-> [(Gdx, AllocSolution)] -> [(Gdx, AllocSolution)]
sortMGResults gl sols = sortMGResults gl sols =
let extractScore = \(_, _, _, x) -> x let extractScore (_, _, _, x) = x
solScore (gdx, sol) = (Group.allocPolicy (Container.find gdx gl), solScore (gdx, sol) = (Group.allocPolicy (Container.find gdx gl),
(extractScore . head . asSolutions) sol) (extractScore . head . asSolutions) sol)
in sortBy (comparing solScore) sols in sortBy (comparing solScore) sols
...@@ -837,8 +834,7 @@ tryMGEvac _ nl il ex_ndx = ...@@ -837,8 +834,7 @@ tryMGEvac _ nl il ex_ndx =
all_insts3 all_insts3
results <- mapM (\(_, gnl, gil, idxs) -> tryEvac gnl gil idxs ex_ndx) results <- mapM (\(_, gnl, gil, idxs) -> tryEvac gnl gil idxs ex_ndx)
all_insts4 all_insts4
let sol = foldl' (\orig_sol group_sol -> let sol = foldl' sumAllocs emptySolution results
sumAllocs orig_sol group_sol) emptySolution results
return $ annotateSolution sol return $ annotateSolution sol
-- | Recursively place instances on the cluster until we're out of space -- | Recursively place instances on the cluster until we're out of space
...@@ -1084,8 +1080,8 @@ instancePriGroup nl i = ...@@ -1084,8 +1080,8 @@ instancePriGroup nl i =
-- | Compute the list of badly allocated instances (split across node -- | Compute the list of badly allocated instances (split across node
-- groups) -- groups)
findSplitInstances :: Node.List -> Instance.List -> [Instance.Instance] findSplitInstances :: Node.List -> Instance.List -> [Instance.Instance]
findSplitInstances nl il = findSplitInstances nl =
filter (not . isOk . instanceGroup nl) (Container.elems il) filter (not . isOk . instanceGroup nl) . Container.elems
-- | Splits a cluster into the component node groups -- | Splits a cluster into the component node groups
splitCluster :: Node.List -> Instance.List -> splitCluster :: Node.List -> Instance.List ->
......
...@@ -7,7 +7,7 @@ has been loaded from external sources. ...@@ -7,7 +7,7 @@ has been loaded from external sources.
{- {-
Copyright (C) 2009, 2010 Google Inc. Copyright (C) 2009, 2010, 2011 Google Inc.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -198,7 +198,7 @@ mergeData um extags exinsts cdata@(ClusterData _ nl il2 tags) = ...@@ -198,7 +198,7 @@ mergeData um extags exinsts cdata@(ClusterData _ nl il2 tags) =
il4 = Container.map (filterExTags allextags . il4 = Container.map (filterExTags allextags .
updateMovable exinsts) il3 updateMovable exinsts) il3
nl2 = foldl' fixNodes nl (Container.elems il4) nl2 = foldl' fixNodes nl (Container.elems il4)
nl3 = Container.map (\node -> Node.buildPeers node il4) nl2 nl3 = Container.map (flip Node.buildPeers il4) nl2
node_names = map Node.name (Container.elems nl) node_names = map Node.name (Container.elems nl)
inst_names = map Instance.name il inst_names = map Instance.name il
common_suffix = longestDomain (node_names ++ inst_names) common_suffix = longestDomain (node_names ++ inst_names)
......
...@@ -213,4 +213,4 @@ parseData (groups, nodes, instances, cinfo) = do ...@@ -213,4 +213,4 @@ parseData (groups, nodes, instances, cinfo) = do
-- | Top level function for data loading -- | Top level function for data loading
loadData :: String -- ^ Unix socket to use as source loadData :: String -- ^ Unix socket to use as source
-> IO (Result ClusterData) -> IO (Result ClusterData)
loadData master = readData master >>= return . parseData loadData = fmap parseData . readData
...@@ -182,4 +182,4 @@ parseData (group_body, node_body, inst_body, tags_body) = do ...@@ -182,4 +182,4 @@ parseData (group_body, node_body, inst_body, tags_body) = do
-- | Top level function for data loading -- | Top level function for data loading
loadData :: String -- ^ Cluster or URL to use as source loadData :: String -- ^ Cluster or URL to use as source
-> IO (Result ClusterData) -> IO (Result ClusterData)
loadData master = readData master >>= return . parseData loadData = fmap parseData . readData
...@@ -188,4 +188,4 @@ parseData fdata = do ...@@ -188,4 +188,4 @@ parseData fdata = do
-- | Top level function for data loading -- | Top level function for data loading
loadData :: String -- ^ Path to the text file loadData :: String -- ^ Path to the text file
-> IO (Result ClusterData) -> IO (Result ClusterData)
loadData afile = readData afile >>= return . parseData loadData = fmap parseData . readData
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment