From ce08735c06515225f4de6cd9cd1d4858c2be034d Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Fri, 31 Oct 2014 22:43:32 +1030 Subject: [PATCH] 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. --- src/cairoint.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cairoint.h b/src/cairoint.h index 07ced422d..5bca00389 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -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