|
1 | 1 | {-# LANGUAGE ViewPatterns #-} |
| 2 | +{-# LANGUAGE ParallelListComp #-} |
2 | 3 |
|
3 | 4 | module Echidna.Output.Source where |
4 | 5 |
|
@@ -39,18 +40,17 @@ zipSumStats :: IO [StatsInfo] -> IO [StatsInfo] -> IO [StatsInfo] |
39 | 40 | zipSumStats v1 v2 = do |
40 | 41 | vec1 <- v1 |
41 | 42 | vec2 <- v2 |
42 | | - return $ zipWith (\a b -> (fst a + fst b, snd a + snd b)) vec1 vec2 |
| 43 | + return [(exec1 + exec2, revert1 + revert2) | (exec1, revert1) <- vec1 | (exec2, revert2) <- vec2] |
43 | 44 |
|
44 | 45 | mvToList :: (VU.Unbox a) => VU.IOVector a -> IO [a] |
45 | 46 | mvToList = fmap U.toList . U.freeze |
46 | 47 |
|
47 | 48 | combineStats :: TLS (IORef StatsMap) -> IO StatsMapV |
48 | 49 | combineStats statsRef = do |
49 | 50 | threadStats' <- allTLS statsRef |
50 | | - threadStats <- sequence $ map readIORef threadStats' :: IO [StatsMap] |
| 51 | + threadStats <- mapM readIORef threadStats' :: IO [StatsMap] |
51 | 52 | statsLists <- pure $ map (\(m :: StatsMap) -> Map.map (\(x :: VU.IOVector StatsInfo) -> mvToList x) m) threadStats :: IO [Map EVM.Types.W256 (IO [StatsInfo])] |
52 | | - stats <- traverse (\x -> x >>= U.thaw . U.fromList >>= U.freeze) $ ((Map.unionsWith) (\(x :: IO [StatsInfo]) (y :: IO [StatsInfo]) -> zipSumStats x y) statsLists) |
53 | | - return stats |
| 53 | + traverse (\x -> x >>= U.thaw . U.fromList >>= U.freeze) $ Map.unionsWith zipSumStats statsLists |
54 | 54 |
|
55 | 55 | saveCoverages |
56 | 56 | :: Env |
@@ -199,8 +199,8 @@ srcMapCov sc covMap statMap contracts = do |
199 | 199 | updateLine (Just (r, q)) = Just ((<> unpackTxResults txResults) r, max q execQty) |
200 | 200 | updateLine Nothing = Just (unpackTxResults txResults, execQty) |
201 | 201 | fileStats = Map.lookup c.runtimeCodehash statMap |
202 | | - idxStats | isJust fileStats = (fromJust fileStats) U.! opIx |
203 | | - | otherwise = (fromInteger 0, fromInteger 0) |
| 202 | + idxStats | isJust fileStats = fromJust fileStats U.! opIx |
| 203 | + | otherwise = (0, 0) |
204 | 204 | execQty = fst idxStats |
205 | 205 | Nothing -> acc |
206 | 206 | Nothing -> acc |
|
0 commit comments