diff options
author | Andreas Voellmy <andreas.voellmy@gmail.com> | 2013-01-07 19:44:31 -0500 |
---|---|---|
committer | Johan Tibell <johan.tibell@gmail.com> | 2013-02-11 21:38:07 -0800 |
commit | f0d1822f8ab6864b5d4bc40d2984dabfb6984e59 (patch) | |
tree | bdf39d93cf0bc66187ad1acca3c5b2b912745f3d /libraries/base/GHC/Event | |
parent | 5b81a90d96404b579eba7f115b5a9b61e2cb4e89 (diff) | |
download | haskell-f0d1822f8ab6864b5d4bc40d2984dabfb6984e59.tar.gz |
Use (.&.) instead of mod in GHC.Event.Manager since the modulus is a power of 2.
Diffstat (limited to 'libraries/base/GHC/Event')
-rw-r--r-- | libraries/base/GHC/Event/Manager.hs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libraries/base/GHC/Event/Manager.hs b/libraries/base/GHC/Event/Manager.hs index da0a461acd..5c0ac0a6e0 100644 --- a/libraries/base/GHC/Event/Manager.hs +++ b/libraries/base/GHC/Event/Manager.hs @@ -52,6 +52,7 @@ import Control.Concurrent.MVar (MVar, modifyMVar, newMVar, readMVar, putMVar, tryPutMVar, takeMVar) import Control.Exception (onException) import Control.Monad ((=<<), forM_, liftM, when, replicateM, void) +import Data.Bits ((.&.)) import Data.IORef (IORef, atomicModifyIORef, mkWeakIORef, newIORef, readIORef, writeIORef) import Data.Maybe (Maybe(..)) @@ -63,7 +64,7 @@ import GHC.Conc.Signal (runHandlers) import GHC.Conc.Sync (yield) import GHC.List (filter) import GHC.Num (Num(..)) -import GHC.Real (fromIntegral, mod) +import GHC.Real (fromIntegral) import GHC.Show (Show(..)) import GHC.Event.Control import GHC.Event.Internal (Backend, Event, evtClose, evtRead, evtWrite, @@ -120,11 +121,12 @@ data EventManager = EventManager , emLock :: MVar () } +-- must be power of 2 callbackArraySize :: Int callbackArraySize = 32 hashFd :: Fd -> Int -hashFd fd = fromIntegral fd `mod` callbackArraySize +hashFd fd = fromIntegral fd .&. (callbackArraySize - 1) {-# INLINE hashFd #-} callbackTableVar :: EventManager -> Fd -> MVar (IM.IntMap [FdData]) |