[Git][ghc/ghc][wip/strict-break] Use lazy break for `lines`

Josh Meredith (@JoshMeredith) gitlab at gitlab.haskell.org
Fri Jan 13 05:29:36 UTC 2023



Josh Meredith pushed to branch wip/strict-break at Glasgow Haskell Compiler / GHC


Commits:
f27fd7d6 by Josh Meredith at 2023-01-13T05:29:12+00:00
Use lazy break for `lines`

- - - - -


2 changed files:

- libraries/base/Data/OldList.hs
- libraries/base/GHC/List.hs


Changes:

=====================================
libraries/base/Data/OldList.hs
=====================================
@@ -1614,7 +1614,7 @@ lines ""                =  []
 -- so s' keeps a reference to the first line via the pair and we have
 -- a space leak (cf. #4334).
 -- So we need to make GHC see the selector thunks with a trick.
-lines s                 =  cons (case break (== '\n') s of
+lines s                 =  cons (case break_ (== '\n') s of
                                     (l, s') -> (l, case s' of
                                                     []      -> []
                                                     _:s''   -> lines s''))


=====================================
libraries/base/GHC/List.hs
=====================================
@@ -34,7 +34,7 @@ module GHC.List (
    head, last, tail, init, uncons, (!!),
    scanl, scanl1, scanl', scanr, scanr1,
    iterate, iterate', repeat, replicate, cycle,
-   take, drop, splitAt, takeWhile, dropWhile, span, break, reverse,
+   take, drop, splitAt, takeWhile, dropWhile, span, break, break_, reverse,
    zip, zip3, zipWith, zipWith3, unzip, unzip3,
    errorEmptyList,
 
@@ -1094,15 +1094,15 @@ span p xs@(x:xs')
 -- ([1,2,3],[])
 --
 -- 'break' @p@ is equivalent to @'span' ('not' . p)@.
-break, break' :: (a -> Bool) -> [a] -> ([a],[a])
+break, break_, break' :: (a -> Bool) -> [a] -> ([a],[a])
 #if defined(USE_REPORT_PRELUDE)
 break_ p                 =  span (not . p)
 #else
 -- HBC version (stolen)
--- break_ _ xs@[]          =  (xs, xs)
--- break_ p xs@(x:xs')
---             | p x       =  ([],xs)
---             | otherwise =  let (ys,zs)   = break_ p xs' in (x:ys,zs)
+break_ _ xs@[]          =  (xs, xs)
+break_ p xs@(x:xs')
+             | p x       =  ([],xs)
+             | otherwise =  let (ys,zs)   = break_ p xs' in (x:ys,zs)
 #endif
 
 break' _ xs@[]          = (xs, xs)



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f27fd7d61fa0730400c7af9cb598031a93905cd9
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/20230113/8b194c62/attachment-0001.html>


More information about the ghc-commits mailing list