Skip to content

Commit

Permalink
Make sure alexScanUser is inlined
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonchinn178 authored and andreasabel committed Dec 30, 2024
1 parent a71aa7f commit 837d2ba
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions data/AlexTemplate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ data AlexReturn a
alexScan input__ IBOX(sc)
= alexScanUser (error "alex rule requiring context was invoked by alexScan; use alexScanUser instead?") input__ IBOX(sc)

-- If the generated alexScan/alexScanUser functions are called multiple times
-- in the same file, alexScanUser gets broken out into a separate function and
-- increases memory usage. Make sure GHC inlines this function and optimizes it.
{-# INLINE alexScanUser #-}

alexScanUser user__ input__ IBOX(sc)
= case alex_scan_tkn user__ input__ ILIT(0) input__ sc AlexNone of
(AlexNone, input__') ->
Expand Down

0 comments on commit 837d2ba

Please sign in to comment.