httpd-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject DO NOT REPLY [Bug 50919] New: potential performance waste caused by sprintf
Date Sat, 12 Mar 2011 22:14:34 GMT

           Summary: potential performance waste caused by sprintf
           Product: Apache httpd-2
           Version: 2.2.17
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: All

           sprintf(q, "%02x", *(unsigned char *)p);

After reading apache codes, I find this code fragment. Using this method to
convert a number into a character which represents a hex number is very slow. 

I give out my patch as follows:

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

 q = hexmap[*(unsigned char *)p]; 

In my unit test, my patch run as 7 times faster than the code fragment I find.
If the code fragment will be executed many times, I believe it can slow down
the whole application. 

I suggest that we should fix this bug.

Configure bugmail:
------- You are receiving this mail because: -------
You are the assignee for the bug.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message