From 379a5711479a3a4de9e9288c65df580d2d15ba90 Mon Sep 17 00:00:00 2001 From: nek0 Date: Wed, 22 Feb 2017 18:03:16 +0100 Subject: [PATCH] a little optimization --- src/Affection/Particle.hs | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/Affection/Particle.hs b/src/Affection/Particle.hs index b6b92b0..9c4b85a 100644 --- a/src/Affection/Particle.hs +++ b/src/Affection/Particle.hs @@ -117,21 +117,25 @@ updateParticleSystem -> Affection us ParticleSystem updateParticleSystem sys sec upd draw = do x <- catMaybes <$> mapM (updateParticle sec upd) (partStorList $ partSysParts sys) + -- liftIO $ traceIO $ show $ length x -- x <- catMaybes <$> foldM (updateParticle sec upd) [] (reverse $ psParts sys) - when (not $ null x) $ do - -- liftIO $ G.gegl_node_link_many $ map particleStackCont (partStorList $ partSysParts sys) - -- liftIO $ traceIO "linking last node to output" - liftIO $ G.gegl_node_link (particleStackCont $ head x) (partSysNode sys) - mapM_ (draw (partSysBuffer sys) (partSysNode sys)) x - return $ sys - { partSysParts = (partSysParts sys) - { partStorList = x - , partStorLatest = - if null x - then Nothing - else partStorLatest (partSysParts sys) - } - } + if (not $ null x) + then do + -- liftIO $ G.gegl_node_link_many $ map particleStackCont (partStorList $ partSysParts sys) + -- liftIO $ traceIO "linking last node to output" + liftIO $ G.gegl_node_link (particleStackCont $ head x) (partSysNode sys) + mapM_ (draw (partSysBuffer sys) (partSysNode sys)) x + return $ sys + { partSysParts = (partSysParts sys) + { partStorList = x + , partStorLatest = + if null x + then Nothing + else partStorLatest (partSysParts sys) + } + } + else + return sys -- | Function for inserting a new 'Particle' into its 'PartileSystem' insertParticle