Closed
Bug 81762
Opened 23 years ago
Closed 23 years ago
Excessive use of strlen
Categories
(SeaMonkey :: UI Design, defect, P3)
SeaMonkey
UI Design
Tracking
(Not tracked)
VERIFIED
FIXED
mozilla0.9.6
People
(Reporter: drepper, Assigned: paulkchen)
References
Details
(Keywords: perf)
Attachments
(2 files, 3 obsolete files)
5.03 KB,
patch
|
jag+mozilla
:
review+
|
Details | Diff | Splinter Review |
1.37 KB,
patch
|
paulkchen
:
review+
|
Details | Diff | Splinter Review |
The files appshell/src/nsCommandLineService.cpp appshell/src/nsCommandLineServiceMac.cpp appshell/src/nsFileLocations.cpp appshell/src/nsUserInfoUnix.cpp contain unnecessary uses of the function nsCRT::strlen which cannot be optimized out by the compiler since it doesn't know the function is the same as strlen. The patch mostly replaces expressions like strlen(foo) > 0 with foo[0] != '\0' or something similar. Only in the file appshell/src/nsCommandLineServiceMac.cpp there is another optimization. The handling of the kCommandLinePrefix and kEnvVarLinePrefix were less than optimal. The changes remove two function calls and two extra variables (the pointers, simply define two arrays). The patch is tested except for the Macintosh portion.
Reporter | ||
Comment 1•23 years ago
|
||
Reporter | ||
Updated•23 years ago
|
nav triage team: Not a beta stopper, marking nsbeta1- and marking future
Keywords: nsbeta1-
Target Milestone: --- → Future
Comment 3•23 years ago
|
||
For whatever it's worth, the patch looks just fine to me (r=rjesup@wgate.com, not that I'm an approved reviewer). Severity -> minor Nominating for 1.0; it's a trivial & safe patch if it hasn't bit-rotted too badly. Probably should remove nsbeta1- I advise dropping Milestone: future.
Keywords: qawanted → mozilla1.0
removing nsbeta1-, marking p3 and mozilla0.9.6
cc-ing Simon to look over the patch and give an sr= if it meets with his approval
Comment 6•23 years ago
|
||
One difference between PR_strlen and strlen is that the former deals gracefully with null strings. That patch should be reviewed with that in mind. rs=sfraser
Attachment #35276 -
Attachment is obsolete: true
Just posted a new patch, main difference is that I don't change from PL_strlen if we don't first check for null.
Reporter | ||
Comment 9•23 years ago
|
||
The new patch isn't correct. Take this: - (void)AddToCommandLine(chars + PL_strlen(kCommandLinePrefix)); + (void)AddToCommandLine(chars + sizeof(kCommandLinePrefix)); This patch changes the behavior since sizeof() counts the terminating \0 byte in while strlen of course doesn't. If you look at my patch you'll see that I added -1 to compensate for that.
Attachment #55754 -
Attachment is obsolete: true
Assignee | ||
Comment 10•23 years ago
|
||
Assignee | ||
Comment 11•23 years ago
|
||
yet another patch, thanks for catching that one
Attachment #55778 -
Attachment is obsolete: true
Assignee | ||
Comment 12•23 years ago
|
||
Assignee | ||
Comment 13•23 years ago
|
||
Ok, new patch. This one is the same as the first patch submitted by Ulrich, the difference is that I add checks for null pointer where needed.
Updated•23 years ago
|
Attachment #55942 -
Flags: review+
Comment 14•23 years ago
|
||
Comment on attachment 55942 [details] [diff] [review] hopefully last patch @@ -168,7 +168,7 @@ rv = GetDomain(getter_Copies(domain)); if (NS_FAILED(rv)) return rv; - if ((const char *)username && (const char*)domain && nsCRT::strlen((const char *)username) && nsCRT::strlen((const char *)domain)) { + if ((const char *)username && (const char*)domain && ((const char *)username)[0] && ((const char *)domain)[0]) { emailAddress = (const char *)username; emailAddress += "@"; emailAddress += (const char *)domain; |domain| and |username| are |nsXPIDLCString|s, so you can just check |IsEmpty()|. Fix that and r=jag.
Assignee | ||
Comment 15•23 years ago
|
||
Assignee | ||
Comment 16•23 years ago
|
||
Comment on attachment 56014 [details] [diff] [review] updated nsUserInfoUnix.cpp patch with jag's suggestion jag said r= if I updated this part
Attachment #56014 -
Flags: review+
Comment 17•23 years ago
|
||
sr=sfraser
Assignee | ||
Comment 18•23 years ago
|
||
checked into trunk and I fixed the blah.IsEmpty() to !blah.IsEmpty() error in my last patch
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Updated•23 years ago
|
QA Contact: sairuh → jrgm
Updated•20 years ago
|
Product: Core → Mozilla Application Suite
You need to log in
before you can comment on or make changes to this bug.
Description
•