Closed
Bug 112209
Opened 23 years ago
Closed 23 years ago
ns*String should be only consumers of nsStr
Categories
(Core :: XPCOM, defect, P2)
Tracking
()
RESOLVED
FIXED
mozilla0.9.9
People
(Reporter: alecf, Assigned: alecf)
References
Details
Attachments
(3 files, 2 obsolete files)
18.92 KB,
patch
|
dbaron
:
review+
bugzilla
:
superreview+
|
Details | Diff | Splinter Review |
2.79 KB,
patch
|
alecf
:
review+
|
Details | Diff | Splinter Review |
1.35 KB,
patch
|
dbaron
:
review+
jst
:
superreview+
|
Details | Diff | Splinter Review |
in an effort to rid ourselves of nsStr, we need to make sure nobody is actually using nsStr outside of the string code. I've found a few occurances, I'll attach patches as I make them
Assignee | ||
Comment 1•23 years ago
|
||
adding scc and dbaron, for reviews
Status: NEW → ASSIGNED
Priority: -- → P2
Target Milestone: --- → mozilla0.9.8
Assignee | ||
Comment 2•23 years ago
|
||
nsStaticNameTable was the only consumer of nsStr::Initialize, and it was using it to create an nsCString that didn't own its own buffer... which is what nsDependentString is for. So, I created a buffer of nsDependentCStrings and used placement-new to initialize the buffer. I had to update the callers as well.
Assignee | ||
Comment 3•23 years ago
|
||
after that patch, there are only 2 more consumers, very little research done here: nsBulletFrame.cpp which uses nsStr::Delete to remove one character nsMsgCompse.cpp, which also uses nsStr::Delete to remove clumps of characters.
Comment on attachment 59355 [details] [diff] [review] convert nsStaticNameTable over to nsDependentString >Index: xpcom/ds/nsStaticNameTable.h >+ const nsDependentCString& GetStringValue(PRInt32 index); I'd prefer if this returned |const nsAFlatString&| rather than |const nsDependentString&| so that we'd have a little more freedom to change the implementation in the future. (You'd also have to fix all the places you did |const nsDependentString& foo = ...|.) >Index: xpcom/ds/nsStaticNameTable.cpp >+ nsMemory::Free((void*)mNameArray); You might at least want to leave a comment that you're assuming that the destructor of nsDependentString is empty. > NS_ASSERTION(temp1.Equals(temp2), "upper case char in table"); I slightly prefer |temp1 == temp2|, but it's your call. >Index: layout/html/base/src/nsTextTransformer.cpp It would be much simpler if you just did this work from the layout module destructor rather than having your own observer. If, when (if?) we start unloading DLLs, we find that the module destructors are doing some of these things too late, we could have one XPCOM shutdown observer per-module and move some of the things from the module destructor into it. >Index: content/shared/public/nsCSSKeywords.h >+ static const nsDependentCString& GetStringValue(nsCSSKeyword aKeyword); Again, I'd prefer |const nsAFlatCString&| to |const nsDependentString&|. >Index: content/shared/public/nsCSSProps.h >+ static const nsDependentCString& GetStringValue(nsCSSProperty aProperty); Again. >+ static const nsDependentCString& LookupPropertyValue(nsCSSProperty aProperty, PRInt32 aValue); And again. >+ static const nsDependentCString& SearchKeywordTable(PRInt32 aValue, const PRInt32 aTable[]); And again.
Assignee | ||
Comment 5•23 years ago
|
||
oh, that nsTextTransformer thing wasn not supposed to be in there! that's bug 112190 I'll add calling the destructor, and convert everyone to nsAFlatCString
Assignee | ||
Comment 6•23 years ago
|
||
- manually call the destructor - changed nsDependentCString to nsAFlatCString
Comment on attachment 59362 [details] [diff] [review] patch addressing dbaron's comments r=dbaron I just noticed one more thing, though -- |IsNullString| is unused, and it doesn't seem too meaningful (since it will return true for any empty string), so why not just get rid of it, and |mNullStr| along with it?
Attachment #59362 -
Flags: review+
Assignee | ||
Updated•23 years ago
|
Attachment #59355 -
Attachment is obsolete: true
Comment 8•23 years ago
|
||
Comment on attachment 59362 [details] [diff] [review] patch addressing dbaron's comments sr=blake
Attachment #59362 -
Flags: superreview+
So now it looks like the page load numbers are 20 seconds slower. I'm really not sure why that would happen -- I would think ToLowerCase ought to be faster than nsString::ToLowerCase, but I could be wrong...
Assignee | ||
Comment 10•23 years ago
|
||
not sure either, but new modern scrollbars also went in in that same build, could also be affecting pageload time
Assignee | ||
Comment 11•23 years ago
|
||
ah, I see. ToLowerCase() is in fact slower, because it calls nsCRT::ToLower() for every character in the string.. nsStr::ChangeCase does everything inline. *sigh* patch to make ToLowerCase() faster coming up
Assignee | ||
Comment 12•23 years ago
|
||
nsCRT::ToLower works one character at a time, and is table-based, which means that every character is getting written back out to memory.. I think that given a reasonably fast processor the arithmetic and range-checking will be faster than a memory lookup (which is what nsCRT::ToLower does)
Assignee | ||
Updated•23 years ago
|
Attachment #59438 -
Attachment description: fast table-based lower/uppercase (exactly how nsCRT::ToLower works anyway) → fast table-based lower/uppercase
Comment on attachment 59438 [details] [diff] [review] fast table-based lower/uppercase >- result = nsCRT::strdup(temp.mStr); >+ result = nsCRT::strdup(temp.get()); In theory, ToNewCString should be faster here, right, since it doesn't have to do the length calculation again? >+ *cp = 'A' + (ch - 'a'); >+ *cp = 'a' + (ch - 'A'); My trust in compilers' ability to optimize is low enough that I think you might be better off rewriting this as: *cp = ch - ('a' - 'A') and *cp = ch + ('a' - 'A')
Comment on attachment 59438 [details] [diff] [review] fast table-based lower/uppercase r=dbaron
Attachment #59438 -
Flags: review+
Assignee | ||
Comment 15•23 years ago
|
||
I've made those changes in my local tree, thanks for the tips
Assignee | ||
Comment 16•23 years ago
|
||
if this is super-reviewed tonight, someone please check it in (I'm gone for the day after posting this..:)) so we don't see slowdowns tomorrow.
Attachment #59438 -
Attachment is obsolete: true
Assignee | ||
Updated•23 years ago
|
Attachment #59458 -
Flags: review+
Comment 17•23 years ago
|
||
Fix checked in, sr=me.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Comment 18•23 years ago
|
||
The figures are still in the 1380 range from the 1360 they were at before the checkin. Could it be something else in the patch that slows pageload down?
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Assignee | ||
Comment 19•23 years ago
|
||
no, I _highly_ doubt anything else in my patch caused the problem. (however, I'm leaving this bug open because this bug is supposed to be for other things)
Status: REOPENED → ASSIGNED
Assignee | ||
Comment 20•23 years ago
|
||
ok, so I may have been hasty there. in any case, the two places to look are: 1) the whole strLower.ToLower() vs. ToLowerCase(strLower) - there might be some slight fixed-time overhead to ToLowerCase(strLower)? I'm not sure on that. 2) nsCStringKey() on an nsDependentCString vs. and nsCString since nsCStringKey's destructor takes an nsAFlatString, I just can't imagine there is much difference.
Assignee | ||
Comment 21•23 years ago
|
||
s/destructor/constructor/
Assignee | ||
Comment 22•23 years ago
|
||
*sigh* 0.9.8 was way to short. moving all my bugs to 0.9.9
Assignee | ||
Updated•23 years ago
|
Target Milestone: mozilla0.9.8 → mozilla0.9.9
Assignee | ||
Comment 23•23 years ago
|
||
ok, current status on this: there are only 2 consumers left: http://lxr.mozilla.org/seamonkey/search?string=nsStr%3A%3A (look at the end, at the files that are not in string/) as a part of another bug, I'm making all other nsStr:: members private/protected so that nobody is ever tempted to use nsStr directly again. This bug will be fixed when we get rid of these two consumers of nsStr::Delete2()
Assignee | ||
Comment 24•23 years ago
|
||
yah! this is it. bye bye. can I get r=dbaron, sr=jag?
Comment on attachment 66367 [details] [diff] [review] fix the last 2 consumers r=dbaron
Attachment #66367 -
Flags: review+
Comment 26•23 years ago
|
||
Comment on attachment 66367 [details] [diff] [review] fix the last 2 consumers sr=jst
Attachment #66367 -
Flags: superreview+
Assignee | ||
Comment 27•23 years ago
|
||
thanks guys! fix has landed.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago → 23 years ago
Resolution: --- → FIXED
Updated•3 years ago
|
Component: String → XPCOM
You need to log in
before you can comment on or make changes to this bug.
Description
•