Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ jobs:
run: |
apt-get update -y
apt-get install -y autoconf build-essential zlib1g-dev libgmp-dev curl libncurses5 libtinfo5 libncurses5-dev libtinfo-dev
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_INSTALL_NO_STACK=1 sh
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_INSTALL_NO_STACK=1 BOOTSTRAP_HASKELL_GHC_VERSION=9.6.7 sh
- uses: actions/checkout@v1 #This version must stay old enough to remain compatible with the container image
- name: Test
run: |
Expand Down
10 changes: 1 addition & 9 deletions Data/ByteString/Char8.hs
Original file line number Diff line number Diff line change
Expand Up @@ -943,21 +943,14 @@ lastnonspace ptr n
-- Note that it __does not__ regard CR (@'\\r'@) as a newline character.
--
lines :: ByteString -> [ByteString]
lines ps
| null ps = []
| otherwise = case search ps of
Nothing -> [ps]
Just n -> take n ps : lines (drop (n+1) ps)
where search = elemIndex '\n'

{-
-- Could be faster, now passes tests...
lines (BS _ 0) = []
lines (BS x l) = go x l
where
nl = c2w '\n'
-- It is important to remain lazy in the tail of the list. The caller
-- might only want the first few lines.
go :: ForeignPtr Word8 -> Int -> [ByteString]
go !f !len = accursedUnutterablePerformIO $ unsafeWithForeignPtr f $ \p -> do
q <- memchr p nl $! fromIntegral len
if q == nullPtr
Expand All @@ -968,7 +961,6 @@ lines (BS x l) = go x l
if j < len
then return $ BS f i : go (plusForeignPtr f j) (len - j)
else return [BS f i]
-}

-- | 'unlines' joins lines, appending a terminating newline after each.
--
Expand Down
4 changes: 4 additions & 0 deletions bench/BenchAll.hs
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,10 @@ main = do
[ bench "map (+1) large" $ nf (S.map (+ 1)) largeTraversalInput
, bench "map (+1) small" $ nf (S.map (+ 1)) smallTraversalInput
]
, bgroup "lines"
[ bench "lazy" $ nf L8.lines $ L8.unlines (map (L8.pack . show) intData)
, bench "strict" $ nf S8.lines $ S8.unlines (map (S8.pack . show) intData)
]
, bgroup "unlines"
[ bench "lazy" $ nf L8.unlines (map (L8.pack . show) intData)
, bench "strict" $ nf S8.unlines (map (S8.pack . show) intData)
Expand Down
Loading