on master help sign in
Add INLINE pragmas for type class instances

This reduces allocation by a decent amount, from 24% of total to 18% of total. It does not have a huge CPU improvement, but it’s still a bit better.

commitcea3cbbb150d281b28acdf5575abcb5651b6d351 authorEvan Czaplicki <evancz@users.noreply.github.com> dateWed 19 Jul 2017, 17:45 (9 years ago) parentca0d6e0
1 file changed+9
src/Parse/Primitives.hs+9
src/Parse/Primitives.hs+9
@@ -177,6 +177,7 @@ endOfFile =
177177
178178
179179instance Functor Parser where
180+ {-# INLINE fmap #-}
180181 fmap f parser =
181182 Parser $ \state cok cerr eok eerr ->
182183 let
@@ -191,12 +192,18 @@ instance Functor Parser where
191192
192193
193194instance Applicative.Applicative Parser where
195+ {-# INLINE pure #-}
194196 pure = return
197+
198+ {-# INLINE (<*>) #-}
195199 (<*>) = ap
196200
197201
198202instance Applicative.Alternative Parser where
203+ {-# INLINE empty #-}
199204 empty = allTheOptionsFailed
205+
206+ {-# INLINE (<|>) #-}
200207 (<|>) = oneOfHelp
201208
202209
@@ -257,10 +264,12 @@ mergeErrors e1@(ParseError r1 c1 p1) e2@(ParseError r2 c2 p2) =
257264
258265
259266instance Monad Parser where
267+ {-# INLINE return #-}
260268 return value =
261269 Parser $ \state _ _ eok _ ->
262270 eok value state noError
263271
272+ {-# INLINE (>>=) #-}
264273 parser >>= callback =
265274 Parser $ \state cok cerr eok eerr ->
266275 let