summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2017-01-23 18:23:32 +1100
committerJed Barber <jjbarber@y7mail.com>2017-01-23 18:23:32 +1100
commitda592e92b4c6b70feb9d1857c8854d77bac25b29 (patch)
treea9874c2e719e3217c534b319a017ed6a3611ec73
parentae2c1edbbfdeb2942ac4c35aeaae6996ae5e6e18 (diff)
Increased speed of vote transfer slightly
-rw-r--r--src/Election.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/Election.hs b/src/Election.hs
index e97eb69..60fd78f 100644
--- a/src/Election.hs
+++ b/src/Election.hs
@@ -280,9 +280,11 @@ addToTransferMap counter mapKeys transferMap traceToAdd = do
let newTraces = map (addToTrace traceToAdd) mapKeys
keyed = zip mapKeys newTraces
noDupes = filter (not . criteriaHasDupe . getCriteria . snd) keyed
- counted <- mapM (\(k,t) -> Sen.doCount counter (getCriteria t) >>= (\x -> return (k,[(x,t)]))) noDupes
- let noZeros = filter ((/= 0) . fst . head . snd) counted
- return (Map.unionWith (++) transferMap (Map.fromList noZeros))
+ counted <- mapM (\(k,t) -> Sen.doCount counter (getCriteria t) >>= (\x -> return (k,(x,t)))) noDupes
+ let notZero (k,xt) = floor ((fromIntegral (fst xt)) * getTransferVal (snd xt)) > 0
+ noZeroMap = filter notZero counted
+ listed = map (\(k,xt) -> (k,xt:[])) noZeroMap
+ return (Map.unionWith (++) transferMap (Map.fromList listed))