[commit: base] : Minor simplification of calculation of new and old events in registerFd_. (adc30bb)

Johan Tibell johan.tibell at gmail.com
Tue Feb 12 07:50:26 CET 2013


Repository : ssh://darcs.haskell.org//srv/darcs/packages/base

On branch  : 

http://hackage.haskell.org/trac/ghc/changeset/adc30bb0e7fe1c7bddbd3e6e7e2cdf8a87dd5666

>---------------------------------------------------------------

commit adc30bb0e7fe1c7bddbd3e6e7e2cdf8a87dd5666
Author: Andreas Voellmy <andreas.voellmy at gmail.com>
Date:   Fri Dec 21 16:04:16 2012 -0500

    Minor simplification of calculation of new and old events in registerFd_.

>---------------------------------------------------------------

 GHC/Event/Manager.hs |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/GHC/Event/Manager.hs b/GHC/Event/Manager.hs
index 067f62d..fb95f7a 100644
--- a/GHC/Event/Manager.hs
+++ b/GHC/Event/Manager.hs
@@ -248,12 +248,17 @@ registerFd_ mgr@(EventManager{..}) cb fd evs = do
         (!newMap, (oldEvs, newEvs)) =
             case IM.insertWith (++) fd' [fdd] oldMap of
               (Nothing,   n) -> (n, (mempty, evs))
-              (Just prev, n) -> (n, pairEvents prev n fd')
+              (Just prev, n) -> (n, (eventsOf prev, combineEvents evs prev))
         modify = oldEvs /= newEvs
     when modify $ I.modifyFd emBackend fd oldEvs newEvs
     return (newMap, (reg, modify))
 {-# INLINE registerFd_ #-}
 
+combineEvents :: Event -> [FdData] -> Event
+combineEvents ev [fdd] = mappend ev (fdEvents fdd)
+combineEvents ev fdds  = mappend ev (eventsOf fdds)
+{-# INLINE combineEvents #-}
+
 -- | @registerFd mgr cb fd evs@ registers interest in the events @evs@
 -- on the file descriptor @fd at .  @cb@ is called for each event that
 -- occurs.  Returns a cookie that can be handed to 'unregisterFd'.





More information about the ghc-commits mailing list