Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add INLINE pragma to encoding functions.

Add INLINE pragma to encoding functions in order to allow
Vector's fusion to kick in.
  • Loading branch information...
commit d13767db3612f1ac45bad3f56d8a42698e6a247b 1 parent 149a2e6
@uu1101 authored
Showing with 4 additions and 0 deletions.
  1. +4 −0 Data/Csv/Encoding.hs
View
4 Data/Csv/Encoding.hs
@@ -73,11 +73,13 @@ decodeByName = decodeByNameWith defaultDecodeOptions
-- | Efficiently serialize CVS records as a lazy 'L.ByteString'.
encode :: ToRecord a => V.Vector a -> L.ByteString
encode = encodeWith defaultEncodeOptions
+{-# INLINE encode #-}
-- | Efficiently serialize CVS records as a lazy 'L.ByteString'. The
-- header is written before any records and dictates the field order.
encodeByName :: ToNamedRecord a => Header -> V.Vector a -> L.ByteString
encodeByName = encodeByNameWith defaultEncodeOptions
+{-# INLINE encodeByName #-}
------------------------------------------------------------------------
-- ** Encoding and decoding options
@@ -127,6 +129,7 @@ encodeWith opts = toLazyByteString
. unlines
. map (encodeRecord (encDelimiter opts) . toRecord)
. V.toList
+{-# INLINE encodeWith #-}
encodeRecord :: Word8 -> Record -> Builder
encodeRecord delim = mconcat . intersperse (fromWord8 delim)
@@ -145,6 +148,7 @@ encodeByNameWith opts hdr v =
. map (encodeRecord (encDelimiter opts)
. namedRecordToRecord hdr . toNamedRecord)
. V.toList $ v
+{-# INLINE encodeByNameWith #-}
namedRecordToRecord :: Header -> NamedRecord -> Record
Please sign in to comment.
Something went wrong with that request. Please try again.