[Git][ghc/ghc][wip/int-index/parser-allocations] Reduce parser allocations

Vladislav Zavialov (@int-index) gitlab at gitlab.haskell.org
Fri Feb 2 23:25:40 UTC 2024



Vladislav Zavialov pushed to branch wip/int-index/parser-allocations at Glasgow Haskell Compiler / GHC


Commits:
2b21c33d by Vladislav Zavialov at 2024-02-03T02:22:40+03:00
Reduce parser allocations

- - - - -


2 changed files:

- compiler/GHC/Parser/Lexer.x
- compiler/GHC/Parser/PostProcess.hs


Changes:

=====================================
compiler/GHC/Parser/Lexer.x
=====================================
@@ -3235,6 +3235,7 @@ instance MonadP P where
   getBit ext = P $ \s -> let b =  ext `xtest` pExtsBitmap (options s)
                          in b `seq` POk s b
   allocateCommentsP ss = P $ \s ->
+    if null (comment_q s) then POk s emptyComments else  -- fast path
     let (comment_q', newAnns) = allocateComments ss (comment_q s) in
       POk s {
          comment_q = comment_q'


=====================================
compiler/GHC/Parser/PostProcess.hs
=====================================
@@ -3060,6 +3060,7 @@ instance MonadP PV where
       let b = ext `xtest` pExtsBitmap (pv_options ctx) in
       PV_Ok acc $! b
   allocateCommentsP ss = PV $ \_ s ->
+    if null (pv_comment_q s) then PV_Ok s emptyComments else  -- fast path
     let (comment_q', newAnns) = allocateComments ss (pv_comment_q s) in
       PV_Ok s {
          pv_comment_q = comment_q'



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2b21c33d71e7cbb58613bcb74a7a5dcdb64fbdf6

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2b21c33d71e7cbb58613bcb74a7a5dcdb64fbdf6
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240202/59d918e6/attachment-0001.html>


More information about the ghc-commits mailing list