on master help sign in
Add INLINE pragmas on TH instance methods
3a0562aHarendra Kumar
core/src/Streamly/Internal/Data/Serialize/TH.hs+6−1
@@ -326,7 +326,11 @@ deriveSerializeInternal preds headTy cons = do
326 peekMethod <- mkDeserializeExpr headTy cons
326 peekMethod <- mkDeserializeExpr headTy cons
327 pokeMethod <- mkSerializeExpr headTy cons
327 pokeMethod <- mkSerializeExpr headTy cons
328 let methods =
328 let methods =
329+ -- INLINE on sizeOf actually worsens some benchmarks, and improves
330+ -- none
331+ [ -- PragmaD (InlineP 'size Inline FunLike AllPhases)
329− [ FunD 'size [Clause [] (NormalB sizeOfMethod) []]
332+ FunD 'size [Clause [] (NormalB sizeOfMethod) []]
333+ , PragmaD (InlineP 'deserialize Inline FunLike AllPhases)
330 , FunD
334 , FunD
331 'deserialize
335 'deserialize
332 [ Clause
336 [ Clause
@@ -336,6 +340,7 @@ deriveSerializeInternal preds headTy cons = do
336 (NormalB peekMethod)
340 (NormalB peekMethod)
337 []
341 []
338 ]
342 ]
343+ , PragmaD (InlineP 'serialize Inline FunLike AllPhases)
339 , FunD
344 , FunD
340 'serialize
345 'serialize
341 [ Clause
346 [ Clause
core/src/Streamly/Internal/Data/Unbox/TH.hs+6−1
@@ -412,7 +412,11 @@ deriveUnboxInternal preds headTy cons = do
412 peekMethod <- mkPeekExpr headTy cons
412 peekMethod <- mkPeekExpr headTy cons
413 pokeMethod <- mkPokeExpr headTy cons
413 pokeMethod <- mkPokeExpr headTy cons
414 let methods =
414 let methods =
415+ -- INLINE on sizeOf actually worsens some benchmarks, and improves
416+ -- none
417+ [ -- PragmaD (InlineP 'sizeOf Inline FunLike AllPhases)
415− [ FunD 'sizeOf [Clause [WildP] (NormalB sizeOfMethod) []]
418+ FunD 'sizeOf [Clause [WildP] (NormalB sizeOfMethod) []]
419+ , PragmaD (InlineP 'peekByteIndex Inline FunLike AllPhases)
416 , FunD
420 , FunD
417 'peekByteIndex
421 'peekByteIndex
418 [ Clause
422 [ Clause
@@ -422,6 +426,7 @@ deriveUnboxInternal preds headTy cons = do
422 (NormalB peekMethod)
426 (NormalB peekMethod)
423 []
427 []
424 ]
428 ]
429+ , PragmaD (InlineP 'pokeByteIndex Inline FunLike AllPhases)
425 , FunD
430 , FunD
426 'pokeByteIndex
431 'pokeByteIndex
427 [ Clause
432 [ Clause