From 4480d0f7c767cfaf37fc0ced4f74d13ccb18da4d Mon Sep 17 00:00:00 2001 From: justin Date: Fri, 29 Oct 2021 17:54:28 +0100 Subject: [PATCH] Fix thunk leak --- src/Dodge/Update.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Dodge/Update.hs b/src/Dodge/Update.hs index da447116b..67d75d8b1 100644 --- a/src/Dodge/Update.hs +++ b/src/Dodge/Update.hs @@ -24,7 +24,7 @@ import Data.List import Data.Maybe import Data.Function import qualified Data.Set as S -import qualified Data.IntMap.Lazy as IM +import qualified Data.IntMap.Strict as IM import Control.Lens import Data.Monoid import System.Random @@ -184,7 +184,9 @@ updateSeenWalls w = foldl' markWallSeen w wallsToUpdate $ nRays 20 markWallSeen :: World -> Wall -> World -markWallSeen w wl = w & walls . ix (_wlID wl) . wlSeen .~ True +markWallSeen w wl = w { _walls = IM.adjust mw (_wlID wl) $ _walls w } + where + mw wl' = wl' {_wlSeen = True} --setTestStringIO :: IO World -> IO World --setTestStringIO = fmap (\ w -> set testString (show $ s w) w) @@ -310,6 +312,6 @@ visibleWalls p1 p2 ws . sortOn (dist p1 . fromJust . fst) . filter ((/=) Nothing . fst) . map f - $ IM.toList ws + $ IM.elems ws where - f (i,wl) = (uncurry intersectSegSeg (_wlLine wl) p1 p2, wl) + f wl = (uncurry intersectSegSeg (_wlLine wl) p1 p2, wl)