diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-02-16 17:22:00 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-02-16 17:22:00 -0400 |
commit | 6591a9b53bdbfdae2b5bef69cfa6bc6e97f0ac35 (patch) | |
tree | 621f20da404867528875d53c62b32bdce5f9fafb /Database | |
parent | 97ed65f674a933e04bea6dcdd8457fdaa31adfdc (diff) |
avoid fromIntegral overhead
Diffstat (limited to 'Database')
-rw-r--r-- | Database/Fsck.hs | 2 | ||||
-rw-r--r-- | Database/Handle.hs | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/Database/Fsck.hs b/Database/Fsck.hs index e52603d9c..a137cba8e 100644 --- a/Database/Fsck.hs +++ b/Database/Fsck.hs @@ -75,4 +75,4 @@ inDb h k = H.runDb h $ do - fsck left off, and making too many commits which slows down the fsck - of lots of small or not present files. -} commitPolicy :: H.CommitPolicy -commitPolicy = H.CommitAfterSeconds 60 +commitPolicy = H.CommitAfter (fromIntegral (60 :: Int)) diff --git a/Database/Handle.hs b/Database/Handle.hs index 59cab0e44..5c4fcca38 100644 --- a/Database/Handle.hs +++ b/Database/Handle.hs @@ -67,7 +67,7 @@ workerThread db jobs = go runDb :: DbHandle -> SqlPersistM a -> IO a runDb h = runDb' h CommitManually -data CommitPolicy = CommitManually | CommitAfterSeconds Int +data CommitPolicy = CommitManually | CommitAfter NominalDiffTime runDb' :: DbHandle -> CommitPolicy -> SqlPersistM a -> IO a runDb' h@(DbHandle _ jobs t) pol a = do @@ -76,11 +76,11 @@ runDb' h@(DbHandle _ jobs t) pol a = do r <- either throwIO return =<< takeMVar res case pol of CommitManually -> return () - CommitAfterSeconds n -> do + CommitAfter n -> do now <- getCurrentTime prev <- takeMVar t putMVar t now - when (diffUTCTime now prev > fromIntegral n) $ + when (diffUTCTime now prev > n) $ commitDb h return r |