Closed
Bug 212475
Opened 22 years ago
Closed 22 years ago
Lazily get mEncoder in nsSegmentEncoder
Categories
(Core :: Networking, defect)
Core
Networking
Tracking
()
VERIFIED
FIXED
People
(Reporter: bzbarsky, Assigned: bzbarsky)
Details
Attachments
(2 files)
|
6.67 KB,
patch
|
darin.moz
:
review-
|
Details | Diff | Splinter Review |
|
8.05 KB,
patch
|
darin.moz
:
review+
dbaron
:
superreview+
|
Details | Diff | Splinter Review |
This goes sort of hand-in-hand with bug 212223. Even in my build that has some
optimizations for GetCharsetAlias (eg caching the service) I see a decent
speedup of nsStandardURL::SetSpec from the patch coming up...
| Assignee | ||
Comment 1•22 years ago
|
||
I put the IsAscii in the same file at jag's suggestion; I don't really see that
many other people using it.....
| Assignee | ||
Updated•22 years ago
|
Attachment #127590 -
Flags: superreview?(dbaron)
Attachment #127590 -
Flags: review?(darin)
Comment 2•22 years ago
|
||
Comment on attachment 127590 [details] [diff] [review]
Proposed patch
>Index: netwerk/base/src/nsStandardURL.h
>+ const char* mCharset; // Caller should keep this alive for
nit: |const char *mCharset;|
>Index: netwerk/base/src/nsStandardURL.cpp
>+inline PRBool
>+IsAscii(const char* str, PRUnichar len)
>+{
>+ // Here "str" is a pointer to a UTF-8 buffer and we must have len
>+ // be smaller than the length to the null terminator
>+ const char* end = str + len;
>+ while (str < end) {
>+ NS_ASSERTION(*str, "Null byte before end of data!");
>+ if (0x80 & *str)
>+ return PR_FALSE;
>+ ++str;
> }
>+ return PR_TRUE;
> }
not too many compilers will inline a function containing
a loop. also, i think this should be in nsCRT. if not,
then when someone down the road needs this maybe they will
not realize that it already exists. plus, this kind of
function deserves to be in a more generic place.
at the very least, move it into nsURLHelper.h (net_IsAscii).
Attachment #127590 -
Flags: review?(darin) → review-
| Assignee | ||
Comment 3•22 years ago
|
||
Attachment #127590 -
Attachment is obsolete: true
| Assignee | ||
Updated•22 years ago
|
Attachment #127590 -
Attachment is obsolete: false
Attachment #127590 -
Flags: superreview?(dbaron)
| Assignee | ||
Updated•22 years ago
|
Attachment #127608 -
Flags: review?(darin)
You could also use
IsAscii(Substring(foo, foo+n))
if you don't want to add a new function for it.
er, IsASCII (in nsReadableUtils).
| Assignee | ||
Comment 6•22 years ago
|
||
Yeah, we were semi-trying to avoid the cost of that; would that be faster than
the "scan the whole string" thing we do right now for typical URI strings?
Comment 7•22 years ago
|
||
Comment on attachment 127608 [details] [diff] [review]
The jag spell has worn off....
r=darin
i think there is good use for this nsCRT function elsewhere in the codebase.
Attachment #127608 -
Flags: review?(darin) → review+
| Assignee | ||
Comment 8•22 years ago
|
||
Comment on attachment 127608 [details] [diff] [review]
The jag spell has worn off....
David, what do you think? Would you rather I went the Substring() route?
Attachment #127608 -
Flags: superreview?(dbaron)
Comment 9•22 years ago
|
||
bz:
have you compared the amount of code generated by
IsAscii(Substring(foo, foo+n))
and
nsCRT::IsAscii(foo, n)
not to mention the overhead of GetReadableFragment, etc. why should we be
creating string objects when we don't need to? ...especially given that this
code is executed A LOT.
| Assignee | ||
Comment 10•22 years ago
|
||
Yes, I know. That's why I wrote it the way I did....
Attachment #127608 -
Flags: superreview?(dbaron) → superreview+
| Assignee | ||
Comment 11•22 years ago
|
||
Checked in. This improved Tp by 1-2%, looks like.....
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Comment 12•22 years ago
|
||
Comment on attachment 127608 [details] [diff] [review]
The jag spell has worn off....
+ static PRBool IsAscii(const char* aString, PRUnichar aLength);
|PRUnichar aLength|???
| Assignee | ||
Comment 13•22 years ago
|
||
Aieee.. Total thinko. Fixed:
-PRBool nsCRT::IsAscii(const char* aString, PRUnichar aLength)
+PRBool nsCRT::IsAscii(const char* aString, PRUint32 aLength)
and similar in the header. Thanks for catching that, jag.
Comment 14•22 years ago
|
||
Is there a whitebox/API test that can verify this change?
Comment 15•22 years ago
|
||
benc: no, not really.
You need to log in
before you can comment on or make changes to this bug.
Description
•