git.iko.soy/typeable/attoparsec
on master help sign in
Fix exponential compilation times due to inlining
eb5cefdJohan Tibell
Data/Attoparsec/ByteString/Internal.hs+1−7
@@ -85,13 +85,9 @@ import qualified Data.ByteString.Unsafe as B
85
85
86#if defined(__GLASGOW_HASKELL__)
86#if defined(__GLASGOW_HASKELL__)
87import GHC.Base (realWorld#)
87import GHC.Base (realWorld#)
88−import GHC.Exts (inline)
89import GHC.IO (IO(IO))
88import GHC.IO (IO(IO))
90#else
89#else
91import System.IO.Unsafe (unsafePerformIO)
90import System.IO.Unsafe (unsafePerformIO)
92−
93−inline :: a -> a
94−inline x = x
95#endif
91#endif
96
92
97type Parser = T.Parser B.ByteString
93type Parser = T.Parser B.ByteString
@@ -116,9 +112,7 @@ ensure' !n0 i0 a0 m0 kf0 ks0 =
116ensure :: Int -> Parser B.ByteString
112ensure :: Int -> Parser B.ByteString
117ensure !n = T.Parser $ \i0 a0 m0 kf ks ->
113ensure !n = T.Parser $ \i0 a0 m0 kf ks ->
118 if B.length (unI i0) >= n
114 if B.length (unI i0) >= n
119− -- Inline the success continuation to avoid creating a closure in
120− -- the common case of enough data in the buffer:
121− then inline ks i0 a0 m0 (unI i0)
115+ then ks i0 a0 m0 (unI i0)
122 -- The uncommon case is kept out-of-line to reduce code size:
116 -- The uncommon case is kept out-of-line to reduce code size:
123 else ensure' n i0 a0 m0 kf ks
117 else ensure' n i0 a0 m0 kf ks
124-- Non-recursive so the bounds check can be inlined:
118-- Non-recursive so the bounds check can be inlined:
Data/Attoparsec/Text/Internal.hs+1−8
@@ -78,13 +78,6 @@ import qualified Data.Text as T
78import qualified Data.Text.Internal as T
78import qualified Data.Text.Internal as T
79import qualified Data.Text.Lazy as L
79import qualified Data.Text.Lazy as L
80
80
81−#if defined(__GLASGOW_HASKELL__)
82−import GHC.Exts (inline)
83−#else
84−inline :: a -> a
85−inline x = x
86−#endif
87−
88type Parser = T.Parser Text
81type Parser = T.Parser Text
89type Result = IResult Text
82type Result = IResult Text
90type Input = T.Input Text
83type Input = T.Input Text
@@ -104,7 +97,7 @@ lengthAtLeast t@(T.Text _ _ len) n = (len `div` 2) >= n || T.length t >= n
104ensure :: Int -> Parser Text
97ensure :: Int -> Parser Text
105ensure !n = T.Parser $ \i0 a0 m0 kf ks ->
98ensure !n = T.Parser $ \i0 a0 m0 kf ks ->
106 if lengthAtLeast (unI i0) n
99 if lengthAtLeast (unI i0) n
107− then inline ks i0 a0 m0 (unI i0)
100+ then ks i0 a0 m0 (unI i0)
108 else runParser (demandInput >> go n) i0 a0 m0 kf ks
101 else runParser (demandInput >> go n) i0 a0 m0 kf ks
109 where
102 where
110 go n' = T.Parser $ \i0 a0 m0 kf ks ->
103 go n' = T.Parser $ \i0 a0 m0 kf ks ->