on develop help sign in
Allow a few more things to be inlined
68e1c18Ryan Trinkle
src/Reflex/Spider/Internal.hs+5−3
@@ -188,6 +188,7 @@ newtype Event x a = Event { subscribeAndRead :: Subscriber x a -> EventM x (Even
188-- | Construct an 'Event' equivalent to that constructed by 'push', but with no
188-- | Construct an 'Event' equivalent to that constructed by 'push', but with no
189-- caching; if the computation function is very cheap, this is (much) more
189-- caching; if the computation function is very cheap, this is (much) more
190-- efficient than 'push'
190-- efficient than 'push'
191+{-# INLINABLE pushCheap #-}
191pushCheap :: (a -> ComputeM x (Maybe b)) -> Event x a -> Event x b
192pushCheap :: (a -> ComputeM x (Maybe b)) -> Event x a -> Event x b
192pushCheap f e = Event $ \sub -> do
193pushCheap f e = Event $ \sub -> do
193 (subscription, occ) <- subscribeAndRead e $ sub
194 (subscription, occ) <- subscribeAndRead e $ sub
@@ -212,6 +213,7 @@ data CacheSubscribed x a
212--TODO: Try a caching strategy where we subscribe directly to the parent when
213--TODO: Try a caching strategy where we subscribe directly to the parent when
213--there's only one subscriber, and then build our own WeakBag only when a second
214--there's only one subscriber, and then build our own WeakBag only when a second
214--subscriber joins
215--subscriber joins
216+{-# INLINABLE cacheEvent #-}
215cacheEvent :: Event x a -> Event x a
217cacheEvent :: Event x a -> Event x a
216cacheEvent e = Event $ \sub -> do
218cacheEvent e = Event $ \sub -> do
217 let !mSubscribedRef = unsafeNewIORef e Nothing
219 let !mSubscribedRef = unsafeNewIORef e Nothing
@@ -1138,7 +1140,7 @@ instance Functor (Event x) where
1138instance Functor (Behavior x) where
1140instance Functor (Behavior x) where
1139 fmap f = pull . fmap f . readBehaviorTracked
1141 fmap f = pull . fmap f . readBehaviorTracked
1140
1142
1141−{-# NOINLINE push #-} --TODO: If this is helpful, we can get rid of the unsafeNewIORef and use unsafePerformIO directly
1143+{-# INLINABLE push #-} --TODO: If this is helpful, we can get rid of the unsafeNewIORef and use unsafePerformIO directly
1142push :: (a -> ComputeM x (Maybe b)) -> Event x a -> Event x b
1144push :: (a -> ComputeM x (Maybe b)) -> Event x a -> Event x b
1143push f e = cacheEvent (pushCheap f e)
1145push f e = cacheEvent (pushCheap f e)
1144{-
1146{-
@@ -1150,7 +1152,7 @@ push f e = eventPush $ Push
1150-- DISABLED: {- RULES "push/push" forall f g e. push f (push g e) = push (maybe (return Nothing) f <=< g) e #-}
1152-- DISABLED: {- RULES "push/push" forall f g e. push f (push g e) = push (maybe (return Nothing) f <=< g) e #-}
1151-}
1153-}
1152
1154
1153−{-# NOINLINE pull #-}
1155+{-# INLINABLE pull #-}
1154pull :: BehaviorM x a -> Behavior x a
1156pull :: BehaviorM x a -> Behavior x a
1155pull a = behaviorPull $ Pull
1157pull a = behaviorPull $ Pull
1156 { pullCompute = a
1158 { pullCompute = a
@@ -1160,7 +1162,7 @@ pull a = behaviorPull $ Pull
1160#endif
1162#endif
1161 }
1163 }
1162
1164
1163−{-# NOINLINE switch #-}
1165+{-# INLINABLE switch #-}
1164switch :: Behavior x (Event x a) -> Event x a
1166switch :: Behavior x (Event x a) -> Event x a
1165switch a = eventSwitch $ Switch
1167switch a = eventSwitch $ Switch
1166 { switchParent = a
1168 { switchParent = a