From 08eca827b659f2becc872c151919948b5a9ffe4d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 16 Oct 2013 21:12:11 +0200 Subject: util/ByteReverse: use C99 "restrict" Micro-optimization. --- src/util/ByteReverse.cxx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/util') diff --git a/src/util/ByteReverse.cxx b/src/util/ByteReverse.cxx index e5367b34c..d1d0a935a 100644 --- a/src/util/ByteReverse.cxx +++ b/src/util/ByteReverse.cxx @@ -18,12 +18,14 @@ */ #include "ByteReverse.hxx" +#include "Compiler.h" #include #include void -reverse_bytes_16(uint16_t *dest, const uint16_t *src, const uint16_t *src_end) +reverse_bytes_16(uint16_t *gcc_restrict dest, + const uint16_t *gcc_restrict src, const uint16_t *src_end) { assert(dest != nullptr); assert(src != nullptr); @@ -36,7 +38,8 @@ reverse_bytes_16(uint16_t *dest, const uint16_t *src, const uint16_t *src_end) } void -reverse_bytes_32(uint32_t *dest, const uint32_t *src, const uint32_t *src_end) +reverse_bytes_32(uint32_t *gcc_restrict dest, + const uint32_t *gcc_restrict src, const uint32_t *src_end) { assert(dest != nullptr); assert(src != nullptr); @@ -49,7 +52,8 @@ reverse_bytes_32(uint32_t *dest, const uint32_t *src, const uint32_t *src_end) } void -reverse_bytes_64(uint64_t *dest, const uint64_t *src, const uint64_t *src_end) +reverse_bytes_64(uint64_t *gcc_restrict dest, + const uint64_t *gcc_restrict src, const uint64_t *src_end) { assert(dest != nullptr); assert(src != nullptr); @@ -62,7 +66,8 @@ reverse_bytes_64(uint64_t *dest, const uint64_t *src, const uint64_t *src_end) } static void -reverse_bytes_linear(uint8_t *dest, const uint8_t *src, size_t n) +reverse_bytes_linear(uint8_t *gcc_restrict dest, + const uint8_t *gcc_restrict src, size_t n) { src += n; @@ -71,8 +76,8 @@ reverse_bytes_linear(uint8_t *dest, const uint8_t *src, size_t n) } static void -reverse_bytes_generic(uint8_t *dest, - const uint8_t *src, const uint8_t *src_end, +reverse_bytes_generic(uint8_t *gcc_restrict dest, + const uint8_t *gcc_restrict src, const uint8_t *src_end, size_t frame_size) { assert(dest != nullptr); @@ -89,7 +94,8 @@ reverse_bytes_generic(uint8_t *dest, } void -reverse_bytes(uint8_t *dest, const uint8_t *src, const uint8_t *src_end, +reverse_bytes(uint8_t *gcc_restrict dest, + const uint8_t *gcc_restrict src, const uint8_t *src_end, size_t frame_size) { assert(dest != nullptr); -- cgit v1.2.3