Closed
Bug 641279
Opened 14 years ago
Closed 1 year ago
potential performance waste caused by sprintf
Categories
(NSS :: Libraries, defect, P5)
NSS
Libraries
Tracking
(Not tracked)
RESOLVED
WONTFIX
People
(Reporter: songlinhai, Unassigned)
Details
(Keywords: perf)
User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.2.15) Gecko/20110303 Firefox/3.6.15
Build Identifier: potential performance waste caused by sprintf
/firefox-4.0b11.source/security/nss/cmd/lib/secutil.c:4111
sprintf(dst, "%02x", *src++);
/firefox-4.0b11.source/security/nss/cmd/certutil/certutil.c:776
sprintf(dst, "%02x", *src++);
After reading mozilla codes, I find these two code fragments. Using this method to convert a number into a string which represents the related hex number is very slow.
This is a patch:
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 ];
}
}
In my unit test, my patch run as 7 times faster as these two code fragments I find. If these two code fragments will be executed many times, I believe it can slow down the whole application.
I suggest that we should fix these two bugs.
Reproducible: Always
Steps to Reproduce:
1.code review
2.
3.
Updated•14 years ago
|
Assignee: nobody → nobody
Component: Security → Libraries
Product: Core → NSS
QA Contact: toolkit → libraries
Comment 1•14 years ago
|
||
Ce Zhang, can you provide a proper patch against the current trunk cvs ?
More Documentation on our processes are at https://developer.mozilla.org/En/Developer_Guide/How_to_Submit_a_Patch and https://developer.mozilla.org/en/Creating_a_patch .
Keywords: perf
Updated•2 years ago
|
Severity: normal → S3
Updated•1 year ago
|
Severity: S3 → S4
Status: UNCONFIRMED → RESOLVED
Closed: 1 year ago
Priority: -- → P5
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•