Hi,

Am Freitag, den 05.08.2016, 22:41 +0000 schrieb [email protected]:
> commit 02614fd61f57b599c5e4fd5e85f00a4e1ce37bc7
> Author: Ömer Sinan Ağacan <[email protected]>
> Date:   Fri Aug 5 20:58:02 2016 +0000
> 
>     Replace some `length . filter` with `count`

Well intended!

I wouldn’t be surprised if this is actually making the code worse,
considering that "count" is implemented in the “wrong”, stackeating way
(whereas lenght . filter could, thanks to list fusion, produce the
desired code)

count :: (a -> Bool) -> [a] -> Int
count _ [] = 0
count p (x:xs) | p x       = 1 + count p xs
               | otherwise = count p xs

I would say that the regression reported by 
https://perf.haskell.org/ghc/#revision/02614fd61f57b599c5e4fd5e85f00a4e1ce37bc7
confirms this, but T6048 is simply unreliable. So practically, it does
not seem to matter either way.

I’ll change the implementation of count.

(Although even then it is not clear that the change is a win, as
"length . filter" might fuse with the producer, whereas "count" without
a lot of extra hassle will not.)

Joachim

-- 
Joachim “nomeata” Breitner
  [email protected]https://www.joachim-breitner.de/
  XMPP: [email protected] • OpenPGP-Key: 0xF0FBF51F
  Debian Developer: [email protected]

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
ghc-devs mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

Reply via email to