on master help sign in
fix more bugs in stepTime
cad54a8Mark Lentczner
Data/UUID/V1.hs+4−4
@@ -65,15 +65,15 @@ stepTime = do
65 h1 <- fmap hundredsOfNanosSinceGregorianReform getCurrentTime
65 h1 <- fmap hundredsOfNanosSinceGregorianReform getCurrentTime
66 if h1 > h0
66 if h1 > h0
67 then do
67 then do
68− writeIORef state $ State 0 h1
68+ writeIORef state $ State c0 h1
69 return $ Just (c0, h1)
69 return $ Just (c0, h1)
70 else do
70 else do
71 let
71 let
72 c1 = succ c0
72 c1 = succ c0
73 if c1 < 2^14
73 if c1 < 2^14
74 then do
74 then do
75− writeIORef state $ State c1 h0
75+ writeIORef state $ State c1 h1
76− return $ Just (c1, h0)
76+ return $ Just (c1, h1)
77 else do
77 else do
78 return Nothing
78 return Nothing
79
79
@@ -81,7 +81,7 @@ stepTime = do
81{-# NOINLINE state #-}
81{-# NOINLINE state #-}
82state = unsafePerformIO $ do
82state = unsafePerformIO $ do
83 h0 <- fmap hundredsOfNanosSinceGregorianReform getCurrentTime
83 h0 <- fmap hundredsOfNanosSinceGregorianReform getCurrentTime
84− newIORef $ State 0 h0
84+ newIORef $ State 0 h0 -- the 0 should be a random number
85
85
86
86
87data State = State
87data State = State