From b61c93b7a1388886fd0b77a7a2927853f3dcdf8b Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Mon, 5 Nov 2012 21:05:42 +0000 Subject: [PATCH] performance: add few restict and const key words This should make the run to be couple percentages quicker. Signed-off-by: Sami Kerola --- src/analyze.c | 6 +++--- src/dhcpd-pools.h | 2 +- src/other.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/analyze.c b/src/analyze.c index b1c1b0a..d8781fd 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -42,7 +42,7 @@ #include "dhcpd-pools.h" /* Clean up data */ -static int ip_sort(struct leases_t *a, struct leases_t *b) +static int ip_sort(const struct leases_t *restrict a, const struct leases_t *restrict b) { if (a->ip < b->ip) return -1; @@ -61,8 +61,8 @@ int prepare_data(void) /* Join leases and ranges into couter structs */ int do_counting(void) { - struct range_t *range_p; - struct leases_t *l; + struct range_t *restrict range_p; + const struct leases_t *restrict l; unsigned long i, k, block_size; range_p = ranges; diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index 2ce3b7c..4237062 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -168,7 +168,7 @@ int do_counting(void); void flip_ranges(struct range_t *__restrict ranges, struct range_t *__restrict tmp_ranges) __attribute__ ((nonnull(1, 2))); /* support functions */ -int xstrstr(char *__restrict a, const char *__restrict b, int len); +int xstrstr(const char *__restrict a, const char *__restrict b, int len); double strtod_or_err(const char *__restrict str, const char *__restrict errmesg); void print_version(void) __attribute__ ((noreturn)); void usage(int status) __attribute__ ((noreturn)); diff --git a/src/other.c b/src/other.c index def337b..dd5e00d 100644 --- a/src/other.c +++ b/src/other.c @@ -50,7 +50,7 @@ int #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) __attribute__ ((hot)) #endif - xstrstr(char *restrict a, const char *restrict b, int len) + xstrstr(const char *restrict a, const char *restrict b, const int len) { int i; /* two spaces are very common in lease file, after them