@@ -7,7 +7,7 @@ module Echidna.Exec where
77import Optics.Core
88import Optics.State.Operators
99
10- import Control.Monad (when , forM_ )
10+ import Control.Monad (when )
1111import Control.Monad.Catch (MonadThrow (.. ))
1212import Control.Monad.State.Strict (MonadState (get , put ), execState , runStateT , MonadIO (liftIO ), gets , modify' , execStateT )
1313import Control.Monad.Reader (MonadReader , ask , asks )
@@ -292,18 +292,16 @@ execTxWithCov tx = do
292292 let size = BS. length . forceBuf . fromJust . view bytecode $ contract
293293 if size == 0 then pure Nothing else do
294294 -- IO for making a new vec
295- vec <- VMut. new size
296295 -- We use -1 for opIx to indicate that the location was not covered
297- forM_ [ 0 .. size - 1 ] $ \ i -> VMut. write vec i (- 1 , 0 , 0 )
296+ vec <- VMut. replicate size (- 1 , 0 , 0 )
298297 pure $ Just vec
299298
300299 statsRef <- getTLS env. statsRef
301300 maybeStatsVec <- lookupUsingCodehashOrInsert env. codehashMap contract env. dapp statsRef $ do
302301 let size = BS. length . forceBuf . fromJust . view bytecode $ contract
303302 if size == 0 then pure Nothing else do
304303 -- IO for making a new vec
305- vec <- VMut. new size
306- forM_ [0 .. size- 1 ] $ \ i -> VMut. write vec i (0 , 0 )
304+ vec <- VMut. replicate size (0 , 0 )
307305 pure $ Just vec
308306
309307 case maybeCovVec of
@@ -320,7 +318,8 @@ execTxWithCov tx = do
320318 (_, depths, results) | depth < 64 && not (depths `testBit` depth) -> do
321319 VMut. write vec pc (opIx, depths `setBit` depth, results `setBit` fromEnum Stop )
322320 writeIORef covContextRef (True , Just (vec, pc))
323- _ -> modifyIORef' covContextRef $ \ (new, _) -> (new, Just (vec, pc))
321+ _ ->
322+ modifyIORef' covContextRef $ \ (new, _) -> (new, Just (vec, pc))
324323
325324 -- | Get the VM's current execution location
326325 currentCovLoc vm = (vm. state. pc, fromMaybe 0 $ vmOpIx vm, length vm. frames)
0 commit comments