--- Comment #4 from Andrei Alexandrescu <and...@metalanguage.com> 2011-12-29
12:25:27 PST ---
(In reply to comment #2)
> (In reply to comment #1)
> > (In reply to comment #0)
> > > In the same way that abs, rol and ror are recognized, bswap(int x)
> > > could be identified from:
> > >
> > > ( x << 24 ) | ( x << 8 ) & 0xff0000 | ( x >> 8 ) & 0xff00 | ( x >> 24 );
> > >
> > > and this would be completely portable.
> > Even if this pattern gets recognized and optimized, I suggest to keep a
> > bswap
> > function in Phobos, to avoid writing all that bug-prone stuff (I'd like a
> > rol/ror function pair too in Phobos).
> Definitely. It would just change from:
> int bswap(int); /* intrinsic */
> int bswap(int x)
> return ( x << 24 ) | ( x << 8 ) & 0xff0000 | ( x >> 8 ) & 0xff00 | ( x >>
> 24 );
I only now realized the meaning of this remark... took me some 10 minutes.
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------