Re: Make Eq type class single method

Sven Panne <[email protected]> Wed, 20 Oct 2021 18:52:19 +0200
Newsgroups gmane.comp.lang.haskell.libraries
Message-ID <CANBN=mt=uvd0C7xRYHf5LiSCCj+r_5LZHvSM63+iRm_R85q=2Q@mail.gmail.com>
Am Mi., 20. Okt. 2021 um 17:17 Uhr schrieb Viktor Dukhovni <
[email protected]>:

> For primitive types CPUs often have both '==' and '/=' instructions,
> and so a direct call to `(/=)` may be more efficient than calling
> `(not .) . (==)`.  [...]


For every native code generator which is worth its salt, this shouldn't
make a difference at all. Swapping the "polarity" of a condition is an
extremely common transformation, which can be used for many reasons. And
even if you don't have anything sophisticated, a simple peephole optimizer
can get rid of the negation operation. And even if all that doesn't help:
Perhaps the negation + condition are fused together in the microcode
operations, depending on your CPU.

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