From fdca8a876083a9b808420aa37b1ce815a3bb9090 Mon Sep 17 00:00:00 2001 From: jgk Date: Fri, 5 Mar 2021 15:27:47 +0100 Subject: [PATCH] Remove space leak on autoDoorPane (hopefully) --- src/Dodge/LevelGen.hs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Dodge/LevelGen.hs b/src/Dodge/LevelGen.hs index 5df9445e0..d940d49ee 100644 --- a/src/Dodge/LevelGen.hs +++ b/src/Dodge/LevelGen.hs @@ -22,6 +22,8 @@ import Picture import System.Random +import Control.DeepSeq (deepseq) + import Control.Monad.State import Data.List import Data.Function @@ -448,8 +450,8 @@ mvPointTowardAtSpeed speed !ep !p | otherwise = p +.+ speed *.* normalizeV (ep -.- p) mvPointToward :: Point2 -> Point2 -> Point2 -mvPointToward ep p | dist p ep < 1 = ep - | otherwise = p +.+ normalizeV (ep -.- p) +mvPointToward !ep !p | dist p ep < 1 = ep + | otherwise = p +.+ normalizeV (ep -.- p) drawAutoDoor :: Wall -> Drawing drawAutoDoor wl = onLayerL [levLayer WlLayer, layer2] @@ -488,7 +490,9 @@ autoDoorPane trigL n castShad closedPos openPos = AutoDoor $ over walls (IM.adjust closeDoor n) w mvP !ep !p = mvPointTowardAtSpeed 2 ep p moveToward :: [Point2] -> Wall -> Wall - moveToward ps w = w & wlLine %~ zipWith mvP ps + moveToward !ps w = let !newPs = zipWith mvP ps $ _wlLine w + in deepseq newPs $ w {_wlLine = newPs} + --deepseq ps $ w & wlLine %~ zipWith mvP ps openDoor = moveToward openPos closeDoor = moveToward closedPos zoneps | dist a b <= 2 * zoneSize = [zoneOfPoint $ pHalf a b]