[cairo-commit] src/cairoint.h

Adrian Johnson ajohnson at kemper.freedesktop.org
Fri Oct 31 05:33:05 PDT 2014


 src/cairoint.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit adbeb3d53c6c6e8ddcc63988200da4c5c9627717
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Fri Oct 31 22:43:32 2014 +1030

    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.

diff --git a/src/cairoint.h b/src/cairoint.h
index 07ced42..5bca003 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


More information about the cairo-commit mailing list