Closed Bug 109179 Opened 24 years ago Closed 24 years ago

replace nsStdEscape with NS_EscapeURL

Categories

(Core :: XPCOM, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla0.9.9

People

(Reporter: darin.moz, Assigned: darin.moz)

References

Details

(Keywords: perf)

Attachments

(1 file, 5 obsolete files)

replace nsStdEscape with NS_EscapeURL to avoid buffer copy when escaping is not necessary. see: http://lxr.mozilla.org/seamonkey/search?string=nsStdEscape for example, the call to nsStdEscape in NS_MakeAbsoluteURLWithCharset should definitely be converted to using NS_EscapeURL. this bug depends on bug 103916, which adds NS_EscapeURL.
Depends on: 103916
-> 0.9.7
Keywords: perf
Priority: -- → P3
Target Milestone: --- → mozilla0.9.7
I will also look into this after the patch for bug 103916 lands.
dp says that nsStdEscape is called 14,134 times at startup (in a 2 week old build, which wouldn't include the patch for bug 103916). in that build, nsStdEscape is .64% of main1, so fixing this bug may give us a significant performance boost at startup.
dp should repeat his test with the new builds, we may have got most of the nsStdEscape usage by the patch in 103916.
true, but it just goes to show that all instances of nsStdEscape should be replaced by NS_EscapeURL.
Component: Layout → XPCOM
Attached patch v1.0 patch (obsolete) — Splinter Review
this patch has only been tested on linux... i'll test on windows and mac before and worry about OS/2 when i check in ;)
Status: NEW → ASSIGNED
Whiteboard: [patch needs testing on win/mac]
Comment on attachment 60576 [details] [diff] [review] v1.0 patch forgot to fix up some calls to nsStdUnescape
Attachment #60576 - Attachment is obsolete: true
Whiteboard: [patch needs testing on win/mac] → [patch needs work]
-> 0.9.8
Target Milestone: mozilla0.9.7 → mozilla0.9.8
andreas: can you review this latest patch? thx!
Comment on attachment 63946 [details] [diff] [review] v1.1 patch - step 1: revise current URL escaping API r=andreas.otte@debitel.net Maybe it should be made more clear in nsEscape.h that esc_Forced is not a mask for an url part but a special mask to force escaping.
Attachment #63946 - Flags: review+
agreed... i'll update the patch.
Comment on attachment 63946 [details] [diff] [review] v1.1 patch - step 1: revise current URL escaping API I'm a little worried that NS_EscapeURLPart no longer truncates its "result" - though it seems intentional. Do we think its worth a potentially confusing semantic change just to optimize the few callers who might want this appending behavior? Assuming there are good reasons for all of this (But let's put them in the bug for good measure) sr=alecf A side suggestion: there isn't really an Adopt() for nsAString, but seems like you're placing an extra burden on the caller to check the resulting value to determine which output to use.... what if you made a NS_Escape(const char *str, PRInt32 len, PRInt16 mask, nsSharableString& result); which wrapped the other NS_Escape, and did an Adopt() to take ownership.. I dunno. CC'ing jag for suggestions
Attachment #63946 - Flags: superreview+
cc'ing jag and dbaron for string usage questions.
alecf: that API would require that nsCAutoString support sharing, which it currently does not. otherwise, we'd suffer a performance loss in the current world. and, Adopt takes a |char *| not a |const char *|, so it wouldn't be useful here. the API i came up with for NS_EscapeURLPart is meant to be a low-level utility function. it doesn't do anymore work then necessary. i can certainly imagine layering other functions on top of NS_EscapeURLPart, but i think the function itself should stay as it is... very basic.
Not quite sure exactly what the string questions were (if any are left), but please spell deprecated correctly. :-)
ok, cool :) sr=alecf still stands of course
Keywords: patch, review
Whiteboard: [patch needs work] → [ready to land part 1]
checked in v1.1 patch (solving the first part of this bug)
Comment on attachment 63946 [details] [diff] [review] v1.1 patch - step 1: revise current URL escaping API marking obsolete since this has been checked in.
Attachment #63946 - Attachment is obsolete: true
Keywords: mozilla0.9.8
Whiteboard: [ready to land part 1]
Comment on attachment 64613 [details] [diff] [review] patch to replace nsStdEscape w/ NS_EscapeURLPart in nsIOServiceXXX leave the OS2 commented #defines unless mike thinks that they should go. r=dougt
Attachment #64613 - Flags: review+
mkaply: any problems with these changes to nsIOServiceOS2.cpp?
Looks good to me. Go ahead and remove the commented out #ifdefs.
Comment on attachment 64613 [details] [diff] [review] patch to replace nsStdEscape w/ NS_EscapeURLPart in nsIOServiceXXX sr=alecf
Attachment #64613 - Flags: superreview+
will land this once the tree opens for mozilla 0.9.9
Target Milestone: mozilla0.9.8 → mozilla0.9.9
so the mac portion of this patch had to be backed out and there was a regression in the windows/os2 builds as a result of this (see bug 122027). i've got a revised patch coming...
tested this patch on the mac. the original patch was backed out on the mac since it caused startup problems. i've verified that the new patch works. was all due to the fact that file:// should have been file:/// :-/
Comment on attachment 66824 [details] [diff] [review] patch - file:// should have been file:/// on mac, windows, and OS/2 r=gagan
Attachment #66824 - Flags: review+
Comment on attachment 66824 [details] [diff] [review] patch - file:// should have been file:/// on mac, windows, and OS/2 sr=waterson
Attachment #66824 - Flags: superreview+
patch checked in.
*** Bug 122043 has been marked as a duplicate of this bug. ***
Attached patch final patch (obsolete) — Splinter Review
removes last reference to nsStdEscape
Attachment #64613 - Attachment is obsolete: true
Attachment #66824 - Attachment is obsolete: true
Comment on attachment 67603 [details] [diff] [review] final patch sr=alecf nice cleanup too.
Attachment #67603 - Flags: superreview+
alecf: thx for the speedy review... i almost forgot that i should also be replacing nsStdUnescape w/ NS_UnescapeURL :-/
Attachment #67603 - Attachment is obsolete: true
this latest patch also fixes a potential memory leak in FTP.
Comment on attachment 67628 [details] [diff] [review] final nsStdEscape patch + removes all instances of nsStdUnescape is there no auto string that we can use? Is your indenting off a bit in nsMsgFolder.cpp?
Attachment #67628 - Flags: review+
nsMsgFolder uses tabs in place of spaces, but not uniformly. i plan to fix up the indentation when i check this in. auto string for what? if you are referring to the places where i capture a char* and call nsMemory::Free explicitly, i think there is no appropriate string class, because the call to NS_UnescapeURL changes the length of the string. it inline decodes escape sequences, which always reduces the length of the string. it just seems like a hack/overkill to use a string class for something like this. nsXPIDLCString foo; bar->GetFoo(getter_Copies(foo)); NS_UnescapeURL((char *) foo.get()); // now, foo.Length is potentially wrong NS_SomeFunction(foo); // watch out!! i'd worry about abusing string code just to avoid explicitly adding nsMemory:: Free calls to the code ;-)
Comment on attachment 67628 [details] [diff] [review] final nsStdEscape patch + removes all instances of nsStdUnescape yeah, const-casting is bad :) but I had a similar question while I was reviewing - can you put some comments saying something to the effect of "using raw pointer because we're modifying the string"? sr=alecf with those patches
Attachment #67628 - Flags: superreview+
will do.
marking FIXED :)
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: