Closed Bug 201670 Opened 22 years ago Closed 22 years ago

nsCollation::UnicodeToChar should cache aCharset, not mEncoderCharsetAtom

Categories

(Core :: Internationalization, defect)

x86
Windows 95
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: neil, Assigned: smontagu)

References

Details

(Keywords: perf)

Attachments

(1 file, 3 obsolete files)

Wondering why it takes Mail 3-4 seconds to sort 12500 strings, I ran jprof and
found that more than half of this time is used within GetCharsetAtom! I
converted it to using an instance reference to the charset alias service, and
jprof now says GetCharsetAtom takes 2/3 of the time and the sort is down to 2-3s.
Attached patch As advertised (obsolete) (deleted) — Splinter Review
Actually I think there's further room for improvement creating collation keys.
Blocks: 63759
I just got a better idea.
Summary: nsCharsetConverterManager should cache charset alias service → nsCollation::UnicodeToChar should cache aCharset, not mEncoderCharsetAtom
Attached patch Proposed patch (obsolete) (deleted) — Splinter Review
Attachment #120207 - Attachment is obsolete: true
Attached file diff -w so you can read it (obsolete) (deleted) —
Comment on attachment 120568 [details] [diff] [review]
Proposed patch

This patch makes sorting messages 200% faster on Linux and probably most other
OSes e.g. Win9x but NOT WinNT which already uses fast native unicode sorting.
Attachment #120568 - Flags: superreview?(sspitzer)
Attachment #120568 - Flags: review?(yokoyama)
This looks good, but could we go further? Could GetDefaultCharsetForLocale
return a charset atom instead of a nsString? (If it has to be a string I would
prefer an nsCString, but that's another story.)
Comment on attachment 120569 [details]
diff -w so you can read it

hmm. I have to agree, why don't we just cache the atom?
OK but I didn't want to go mucking around with the interfaces without approval.
approval from whom? :) as long as the interface isn't marked FROZEN (and maybe
UNDER_REVIEW) then the interface is just like any other code - you get the right
module owner review and/or approval and so forth..

Attached patch New approach (deleted) — Splinter Review
OK, so have I got this right?
The only user of nsCollation is nsCollation<platform>.
These never change mCharset after they create nsCollation.
So, they can pass mCharset to a nsCollation method to create the converter.
In fact, I pass the PRUnichar * to save some conversions.
If you forget or fail to set the charset then it falls back on ISO-8859-1.
Attachment #120568 - Attachment is obsolete: true
Attachment #120569 - Attachment is obsolete: true
Comment on attachment 120821 [details] [diff] [review]
New approach

OS/2 never does unicode conversion so I just junked all the charset code.
Attachment #120821 - Flags: superreview?(alecf)
Attachment #120821 - Flags: review?(smontagu)
Oh, and should this get r+sr feel free to check it in before I can on Tuesday.
Blocks: 181515
Comment on attachment 120821 [details] [diff] [review]
New approach

nice. this is a million times better. Sorry for the delay in reading it...

sr=alecf

smontagu, can you r= this  in time for 1.4 beta?
Attachment #120821 - Flags: superreview?(alecf) → superreview+
Comment on attachment 120821 [details] [diff] [review]
New approach

r=smontagu
Attachment #120821 - Flags: review?(smontagu) → review+
cc-ing mkaply in case there are issues with comment 12.
Neil and I talked about this and we think we are OK.
Fix checked in.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
good work, this may help bug 160140
Blocks: 160140
Attachment #120568 - Flags: superreview?(sspitzer)
Attachment #120568 - Flags: review?(yokoyama)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: