Re: Method MaildirFolder.appendMessages Optimizations

Chris Burdess <[email protected]> Sat, 18 Jan 2014 16:54:42 +0000
Newsgroups gmane.comp.java.classpath.extensions.javamail
Message-ID <[email protected]>
On 18/01/14 00:40, Conrad T. Pino wrote:
>
> I propose 2 optimizations to Subject method:
>
> 1.	Since Subject method is declared synchronized the synchronized block
> consisting of lines 429-430 & 501 is pointless.
>
> 2.	The if statements at lines 499 and 503 should be merged.
>
> If the original intent was to conduct notifyMessageAddedListeners outside
> the lock scope then the Subject method declaration should not be
> synchronized.

The method declaration needs to be not synchronized, so that we can
actually fire the events outside the synchronized block.

> This is a very small nit:
>
> *	Line 500 reads: appended.toArray(n);
>
> *	I suggest "n = appended.toArray(n);" is a worthwhile defense against
> non-compliant implementations.
> *	I suppose implementations could be non-compliant in the other
> direction too.
> *	What does our collective experience suggest as the best practice?

If the implementation is this broken you probably have worse things to
worry about. Certainly I've never come across an implementation that
didn't do what the API says it does for this method.