httpd-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 50919] potential performance waste caused by sprintf
Date Sun, 13 Mar 2011 00:13:49 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=50919

--- Comment #2 from Linhai Song <songlinhai0543@gmail.com> 2011-03-12 19:13:47 EST ---
(In reply to comment #1)
> It appears you have compressed 2^8 bits into 2^4 bit representation, is that
> what you meant to do?
> 
> Have you tested this with mapping to hexmap[(p >> 4)& 15] . hexmap[p &
15]...
> and using a 256 char hexmap?

yes, this is what I mean


I write a wrong patch, and very sorry for the mistake.

the correct patch is 

static char _dig_vec_lower[]= { '0', '1', '2', '3', '4', '5', '6', '7', '8',
'9', 'a','b', 'c', 'd', 'e', 'f' };

static void array_to_hex( char * to , const char * str , unsigned char  len )
{

    const char * str_end = str + len;
    for( ; str != str_end ; ++ str )
    {
       *to++ = _dig_vec_lower[ ((unsigned char) *str) >> 4 ];
       *to++ = _dig_vec_lower[ ((unsigned char) *str) & 0x0F ];
    }
}

my unit test is using this patch, and it is more than 7 times faster than
calling sprintf.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


Mime
View raw message