Commit b4bae394 authored by Iustin Pop's avatar Iustin Pop
Browse files

htools: small optimisation in Cluster.collapseFailures



This makes fewer temporary data structures, and thus brings a bit of
improvement in total runtime.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 8f48f67d
...@@ -603,7 +603,8 @@ tryBalance ini_tbl disk_moves inst_moves evac_mode mg_limit min_gain = ...@@ -603,7 +603,8 @@ tryBalance ini_tbl disk_moves inst_moves evac_mode mg_limit min_gain =
-- | Build failure stats out of a list of failures. -- | Build failure stats out of a list of failures.
collapseFailures :: [FailMode] -> FailStats collapseFailures :: [FailMode] -> FailStats
collapseFailures flst = collapseFailures flst =
map (\k -> (k, length $ filter (k ==) flst)) [minBound..maxBound] map (\k -> (k, foldl' (\a e -> if e == k then a + 1 else a) 0 flst))
[minBound..maxBound]
-- | Update current Allocation solution and failure stats with new -- | Update current Allocation solution and failure stats with new
-- elements. -- elements.
......
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