Skip to content
Browse files

INLINE some functions, and strictify certain expressions

  • Loading branch information...
1 parent 899dc10 commit 9b0fddc8ae4f16f2650b5c842f5adb4d287e414a @JohnLato committed Feb 27, 2012
Showing with 14 additions and 11 deletions.
  1. +1 −0 Data/Iteratee/Offset.hs
  2. +9 −7 Data/Iteratee/ZoomCache.hs
  3. +3 −3 Data/ZoomCache/Numeric/Internal.hs
  4. +1 −1 zoom-cache.cabal
View
1 Data/Iteratee/Offset.hs
@@ -34,6 +34,7 @@ tell = I.liftI step
| LL.null vec = I.liftI step
| otherwise = I.idone o s
step stream = I.icont step (Just (I.setEOF stream))
+{-# INLINE tell #-}
----------------------------------------------------------------------
View
16 Data/Iteratee/ZoomCache.hs
@@ -108,10 +108,10 @@ import Data.ZoomCache.Types
data Block = Block
{ blkFile :: CacheFile
, blkTrack :: TrackNo
- , blkData :: BlockData
+ , blkData :: !BlockData
}
-data BlockData = BlockPacket PacketSO | BlockSummary ZoomSummarySO
+data BlockData = BlockPacket !PacketSO | BlockSummary !ZoomSummarySO
instance Timestampable Block where
timestamp (Block c t (BlockPacket p)) = timestamp (packetFromCTPSO (c,t,p))
@@ -323,17 +323,17 @@ enumBlockTrackNo cf0 trackNo = I.unfoldConvStreamCheck I.eneeCheckIfDoneIgnore g
iterBlock :: (Functor m, MonadIO m)
=> CacheFile
-> Iteratee (Offset ByteString) m (CacheFile, [Offset Block])
-iterBlock cf = do
+iterBlock cf = {-# SCC "iterBlock" #-} do
I.dropWhile (/= headerMarker)
o <- OffI.tell
header <- OffI.takeBS 8
case parseHeader header of
Just PacketHeader -> do
- (trackNo, packet) <- OffI.convOffset $ readPacket (cfSpecs cf)
- return $ maybe (cf, []) (retPacket trackNo o) packet
+ (!trackNo, packet) <- OffI.convOffset $ readPacket (cfSpecs cf)
+ return $! maybe (cf, []) (retPacket trackNo o) packet
Just SummaryHeader -> do
- (trackNo, summary) <- OffI.convOffset $ readSummaryBlock (cfSpecs cf)
- return $ maybe (cf, []) (retSummary trackNo o) summary
+ (!trackNo, summary) <- OffI.convOffset $ readSummaryBlock (cfSpecs cf)
+ return $! maybe (cf, []) (retSummary trackNo o) summary
_ -> return (cf, [])
where
retPacket trackNo o p = (cf', [Offset o (Block cf' trackNo (BlockPacket p))])
@@ -357,6 +357,7 @@ iterBlock cf = do
where
f Nothing = Just o
f (Just o0) = Just (min o0 o)
+{-# INLINE iterBlock #-}
-- | An iteratee of zoom-cache data, after global and track headers
-- have been read, or if the 'CacheFile' has been acquired elsewhere.
@@ -607,6 +608,7 @@ readSummaryBlockData specs trackNo lvl entryTime exitTime byteLength =
readSummaryAs :: (ZoomReadable a, Functor m, Monad m)
=> a -> Iteratee ByteString m (SummaryData a)
readSummaryAs = const readSummary
+{-# INLINE readSummaryBlockData #-}
----------------------------------------------------------------------
View
6 Data/ZoomCache/Numeric/Internal.hs
@@ -29,9 +29,9 @@ import Data.ZoomCache.Numeric.Types
readSummaryNum :: (Functor m, Monad m, ZoomNum a)
=> Iteratee ByteString m (SummaryData a)
readSummaryNum = do
- [en,ex,mn,mx] <- replicateM 4 readRaw
- [avg,rms] <- replicateM 2 readDouble64be
- return (numMkSummary en ex mn mx avg rms)
+ [!en,!ex,!mn,!mx] <- replicateM 4 readRaw
+ [!avg,!rms] <- replicateM 2 readDouble64be
+ return $! numMkSummary en ex mn mx avg rms
{-# INLINE readSummaryNum #-}
fromSummaryNum :: ZoomNum a
View
2 zoom-cache.cabal
@@ -3,7 +3,7 @@ Name: zoom-cache
-- The package version. See the Haskell package versioning policy
-- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for
-- standards guiding when and how versions should be incremented.
-Version: 1.2.1.0
+Version: 1.2.1.1
Synopsis: A streamable, seekable, zoomable cache file format

0 comments on commit 9b0fddc

Please sign in to comment.
Something went wrong with that request. Please try again.