Improve performance of cpu_to_be32 and be32_to_cpu

By switching to the more common form, gcc and clang emit a single
bswap instruction and truetype subsetting of large fonts runs about
15% faster.
This commit is contained in:
Adrian Johnson 2014-10-31 22:43:32 +10:30 committed by Bryce Harrington
parent 956ef874c8
commit ce08735c06

View file

@ -229,7 +229,7 @@ be16_to_cpu(uint16_t v)
static inline uint32_t cairo_const
cpu_to_be32(uint32_t v)
{
return (cpu_to_be16 (v) << 16) | cpu_to_be16 (v >> 16);
return (v >> 24) | ((v >> 8) & 0xff00) | ((v << 8) & 0xff0000) | (v << 24);
}
static inline uint32_t cairo_const