Closed
Bug 92641
Opened 23 years ago
Closed 23 years ago
nsIOService::NewURI strdup's the scheme when it doesn't need to
Categories
(Core :: Networking, defect)
Tracking
()
RESOLVED
FIXED
mozilla0.9.4
People
(Reporter: jesup, Assigned: jesup)
References
Details
(Keywords: perf)
Attachments
(2 files)
(deleted),
patch
|
Details | Diff | Splinter Review | |
(deleted),
patch
|
Details | Diff | Splinter Review |
nsIOService::NewURI strdup's the scheme when it doesn't need to. I have a patch
that avoid's strduping it for URI's with a scheme (I may extend to to some
relative URI's as well). This is called circa 1100 times at startup according
to Suresh Duddi <dpsuresh@netscape.net>.
Assignee | ||
Updated•23 years ago
|
Comment 1•23 years ago
|
||
->dougt, who was looking at string allocations (unless Randell wants to take this)
Assignee: neeti → dougt
Assignee | ||
Comment 2•23 years ago
|
||
I'll take it; I already have a patch coded up (will upload on monday).
Assignee: dougt → rjesup
Assignee | ||
Comment 3•23 years ago
|
||
Assignee | ||
Comment 4•23 years ago
|
||
patch posted; targeting 0.9.4.
Anyone who can, r/sr please. According to the posts in .performance, there are
at least 1000 uses of this at startup, almost all of which are making an extra
allocation of the scheme, so this should save circa 1000 alloc/frees at startup.
Future work might be to make the scheme not be allocated in either absolute or
relative cases.
Comment 5•23 years ago
|
||
+ if (end != 0 ? !nsCRT::strncasecmp(&scheme[start], gScheme[i],
+ (end-start)-1) :
+ !nsCRT::strcasecmp(scheme, gScheme[i]))
That was a new construction to me. Took a couple of seconds to figure it out.
Why not:
PRBool foundScheme;
if (end == 0)
foundScheme = !nsCRT::strcasecmp(scheme, gScheme[i])
else
foundScheme = !nsCRT::strncasecmp(&scheme[start], gScheme[i],
(end-start)-1);
if (foundScheme)
But the idea seems right.
Assignee | ||
Comment 6•23 years ago
|
||
Habit. Totally readable to me to avoid an extra localvar. Any r=/sr=, or if
reviewers object, I can recode as Daniel suggests.
Comment 7•23 years ago
|
||
Seems like you could use an XPIDLCString for scheme and remove the free call.
Other than that, sr=hyatt
Comment 8•23 years ago
|
||
what hyatt said. r=dougt
Assignee | ||
Comment 9•23 years ago
|
||
Assignee | ||
Comment 10•23 years ago
|
||
hyatt, dougt: Please either re-review or just tell me to check in.
The only change was to use an nsXPIDLCString as suggested. I hadn't before
because the original code didn't use one (it did explicit frees). Thanks.
Assignee | ||
Comment 11•23 years ago
|
||
Added waterson; he's my check-in buddy on this. I think we're ready to check in.
Assignee | ||
Comment 12•23 years ago
|
||
Fix checked in
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•