From: Justin Erenkrantz Date: Thu, 30 May 2002 08:32:09 +0000 (+0000) Subject: Unroll the putLong and getLong loops and correct putLong's input param type to X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=726b0edbf4cffd8cd0f4fd255b0236c82f22420b;p=apache Unroll the putLong and getLong loops and correct putLong's input param type to be unsigned char* instead of char*. Submitted by: Sander Striker Reviewed by: Justin Erenkrantz git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95397 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/filters/mod_deflate.c b/modules/filters/mod_deflate.c index 64b5836b1f..25fda5822b 100644 --- a/modules/filters/mod_deflate.c +++ b/modules/filters/mod_deflate.c @@ -138,29 +138,22 @@ typedef struct deflate_filter_config_t /* Outputs a long in LSB order to the given file * only the bottom 4 bits are required for the deflate file format. */ -static void putLong(char *string, unsigned long x) +static void putLong(unsigned char *string, unsigned long x) { - int n; - for (n = 0; n < 4; n++) { - string[n] = (int) (x & 0xff); - x >>= 8; - } + string[0] = (unsigned char)(x & 0xff); + string[1] = (unsigned char)((x & 0xff00) >> 8); + string[2] = (unsigned char)((x & 0xff0000) >> 16); + string[3] = (unsigned char)((x & 0xff000000) >> 24); } /* Inputs a string and returns a long. */ static unsigned long getLong(unsigned char *string) { - int n = 3; - unsigned long x = 0; - - while (n) { - x |= (unsigned long)(string[n--]) & 0xff; - x <<= 8; - } - - x |= (unsigned long)(string[0]) & 0xff; - return x; + return ((unsigned long)string[0]) + | (((unsigned long)string[1]) << 8) + | (((unsigned long)string[2]) << 16) + | (((unsigned long)string[3]) << 24); } static void *create_deflate_server_config(apr_pool_t *p, server_rec *s)