Closed Bug 123699 Opened 23 years ago Closed 23 years ago

Cache MIME converter in nsMsgI18N.cpp

Categories

(MailNews Core :: Internationalization, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla0.9.9

People

(Reporter: nhottanscp, Assigned: nhottanscp)

References

Details

Attachments

(1 file, 2 obsolete files)

nsMsgI18NEncodeMimePartIIStr creates the converter object everytime it's called. That can be cached and released at shutdown. http://lxr.mozilla.org/seamonkey/source/mailnews/base/util/nsMsgI18N.cpp#399
Blocks: 115288
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla0.9.9
Attached patch Cache MIME converter. (obsolete) (deleted) — Splinter Review
Attachment #68036 - Attachment is obsolete: true
Is this thread-safe?
The threading issue seems to be okay since the Mime Converter only lives on the UI thread. But I need to find a way to remove the shutdown observer.
It turned out that I don't need to remove it, it is taken care by XPCOM.
Comment on attachment 68056 [details] [diff] [review] Cache MIME converter and added MIME decoder function. looks good. R=ducarroz
They are exposed to public. Even though it's used by UI thread only today, it may be used by someone else tomorrow. At least, it must have a mutex to block multiple calls. A better implementation would cache multiple instances of converter so that blocking won't occur until number of concurrent calls reaches the number of cached instances.
Comment on attachment 68056 [details] [diff] [review] Cache MIME converter and added MIME decoder function. Naoki, why don't we just invoke the MimeConverter as a service directly in your I18n util routines (nsMsgI18NDecoderMimePartIIStr and the routine above it). If you invoke it as a service, we will only create one instance of the object and we'll cache it, always re-using that same instance. This way, you let the service manager manage the life time of your decoder object. Then you can remove your static global variable, your class which becomes an xpcom shutdown observer just so you can release your class, and your InitializeMsgI18NGlobals routine. The service manager does all of that for you already. That would reduce your patch to just a couple lines I think.
I agree, mark this as WONTFIX.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → WONTFIX
why is this a won't fix? You still need a patch that invokes the decoder as a service for these two routines. Shouldn't that patch go in this bug?
I forgot that there is an existing code for the encoder. I am going to change it to use a service. For decoder, the client can get a service by itself, so I won't add the function.
Status: RESOLVED → REOPENED
Resolution: WONTFIX → ---
Attachment #68056 - Attachment is obsolete: true
Comment on attachment 69317 [details] [diff] [review] Change to use the service manager for mime converter. sr=mscott
Attachment #69317 - Flags: superreview+
Comment on attachment 69317 [details] [diff] [review] Change to use the service manager for mime converter. oops one little comment. the component manager will return an error if it couldn't create a mime converter so you don't need the nsnull != converter if you leave it, just do NS_SUCCEEDED(res) && converter which is much easier to read than the null comparison.
checked in
Status: REOPENED → RESOLVED
Closed: 23 years ago23 years ago
Resolution: --- → FIXED
Naoki, could you help verifying this? Thanks.
QA Contact: ji → nhotta
Product: MailNews → Core
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: