[cairo] Speeding up _cairo_fixed_from_double
Owen Taylor
otaylor at redhat.com
Sun Oct 29 13:59:32 PST 2006
On Sun, 2006-10-29 at 14:04 -0500, Jim Gettys wrote:
> Evil endianness trick from Xlib:
>
> int endian = 1;
>
> if (*(char *) &endian)
> client.byteOrder = '\154'; /* 'l' */
> else
> client.byteOrder = '\102'; /* 'B' */
>
> Even more fun about this, is that the compiler ends up optimizing
> exactly what you'd like; everything is determinable at compile time, so
> only the right assignment (or branch set of code) is emitted in the
> generated code.
I can't believe that I'm contributing more to this discussion... but
I was skeptical that the compiler would actually optimize the above,
so I tried it and GCC-4.1.1, at least, doesn't.
- Owen
More information about the cairo
mailing list