Skip to content

Commit

Permalink
Change a use of atomicModifyIORef to atomicModifyIORef'
Browse files Browse the repository at this point in the history
Resulting core is unchanged.
  • Loading branch information
Ian Lynagh committed Jun 8, 2013
1 parent d4d008b commit ddbe37f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Data/Unique.hs
Expand Up @@ -55,8 +55,8 @@ uniqSource = unsafePerformIO (newIORef 0)
-- times 'newUnique' may be called.
newUnique :: IO Unique
newUnique = do
r <- atomicModifyIORef uniqSource $ \x -> let z = x+1 in (z,z)
r `seq` return (Unique r)
r <- atomicModifyIORef' uniqSource $ \x -> let z = x+1 in (z,z)
return (Unique r)

-- SDM (18/3/2010): changed from MVar to STM. This fixes
-- 1. there was no async exception protection
Expand All @@ -73,6 +73,10 @@ newUnique = do
-- Unique.
-- 3. IORef version is very slightly faster.

-- IGL (08/06/2013): changed to using atomicModifyIORef' instead.
-- This feels a little safer, from the point of view of not leaking
-- memory, but the resulting core is identical.

-- | Hashes a 'Unique' into an 'Int'. Two 'Unique's may hash to the
-- same value, although in practice this is unlikely. The 'Int'
-- returned makes a good hash key.
Expand Down

0 comments on commit ddbe37f

Please sign in to comment.