on develop help sign in
Small performance improvement for elDynAttr
773de9bDoug Beardsley
src/Reflex/Dom/Widget/Basic.hs+10−8
@@ -351,14 +351,16 @@ dynamicAttributesToModifyAttributes = dynamicAttributesToModifyAttributesWithIni
351dynamicAttributesToModifyAttributesWithInitial :: (Ord k, PostBuild t m) => Map k Text -> Dynamic t (Map k Text) -> m (Event t (Map k (Maybe Text)))
351dynamicAttributesToModifyAttributesWithInitial :: (Ord k, PostBuild t m) => Map k Text -> Dynamic t (Map k Text) -> m (Event t (Map k (Maybe Text)))
352dynamicAttributesToModifyAttributesWithInitial attrs0 d = do
352dynamicAttributesToModifyAttributesWithInitial attrs0 d = do
353 postBuild <- getPostBuild
353 postBuild <- getPostBuild
354− let modificationsNeeded = flip pushAlways (align postBuild $ updated d) $ \case
354+ let modificationsNeeded = flip push (align postBuild $ updated d) $ \x -> do
355+ p <- case x of
355− This () -> do
356+ This () -> do
356− new <- sample $ current d
357+ new <- sample $ current d
357− return $ diffMap attrs0 new
358+ return $ diffMap attrs0 new
358− These () new -> return $ diffMap attrs0 new
359+ These () new -> return $ diffMap attrs0 new
359− That new -> do
360+ That new -> do
360− old <- sample $ current d
361+ old <- sample $ current d
361− return $ diffMap old new
362+ return $ diffMap old new
363+ return $ if Map.null p then Nothing else Just p
362 return modificationsNeeded
364 return modificationsNeeded
363
365
364--------------------------------------------------------------------------------
366--------------------------------------------------------------------------------