on develop help sign in
Small performance improvement for elDynAttr
commit773de9be7749b6a5bb55966d1a2632782d9bcde7 authorDoug Beardsley <mightybyte@gmail.com> dateMon 24 Apr 2017, 13:31 (10 years ago) parentaebb0fe
1 file changed+10−8
src/Reflex/Dom/Widget/Basic.hs+10−8
src/Reflex/Dom/Widget/Basic.hs+10−8
@@ -351,14 +351,16 @@ dynamicAttributesToModifyAttributes = dynamicAttributesToModifyAttributesWithIni
351351dynamicAttributesToModifyAttributesWithInitial :: (Ord k, PostBuild t m) => Map k Text -> Dynamic t (Map k Text) -> m (Event t (Map k (Maybe Text)))
352352dynamicAttributesToModifyAttributesWithInitial attrs0 d = do
353353 postBuild <- getPostBuild
354− let modificationsNeeded = flip pushAlways (align postBuild $ updated d) $ \case
355− This () -> do
356− new <- sample $ current d
357− return $ diffMap attrs0 new
358− These () new -> return $ diffMap attrs0 new
359− That new -> do
360− old <- sample $ current d
361− return $ diffMap old new
354+ let modificationsNeeded = flip push (align postBuild $ updated d) $ \x -> do
355+ p <- case x of
356+ This () -> do
357+ new <- sample $ current d
358+ return $ diffMap attrs0 new
359+ These () new -> return $ diffMap attrs0 new
360+ That new -> do
361+ old <- sample $ current d
362+ return $ diffMap old new
363+ return $ if Map.null p then Nothing else Just p
362364 return modificationsNeeded
363365
364366--------------------------------------------------------------------------------