james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Harmeet Bedi" <harm...@kodemuse.com>
Subject Re: String.equalsIgnoreCase Considered Evil :-)
Date Mon, 05 Aug 2002 23:21:14 GMT
v1.150.  As the attached
> program illustrates,

Very impressive turnaround. :-)
I had always tool it for granted that <equalsIgnoreCase> pattern is better.

There is the additional object creation with toUpperCase method. Minor thing
though... I think the changes are good.

Harmeet

----- Original Message -----
From: "Noel J. Bergman" <noel@devtech.com>
To: "James Developers List" <james-dev@jakarta.apache.org>
Sent: Monday, August 05, 2002 1:06 PM
Subject: RE: String.equalsIgnoreCase Considered Evil :-)


>
> I am running with JDK 1.4, which has String.java v1.150.  As the attached
> program illustrates, using String.equalsIgnoreCase is faster than using
> String.equals for the first command on the chain, about break-even for the
> second, and generally slower for all other commands.
>
> One reason for this is that String.toUpperCase is optimized.  In the
normal
> event that the SMTP client passes upper case commands across the wire,
> String.toUpperCase simply returns the original string.
>
> However, even in the case where the command is passed in lower case, the
> result is simply shifted a couple of comparisons down the chain.  And
since
> we have not sorted the command chain by frequency of use, commands such as
> DATA and RETR are slower with the original code.  When we get to handlers
> such as IMAP which have a more extensive and active set of commands, the
> impact will be even greater.  Oh, and there is also an impact based upon
> command length, which is why TOP is faster with equalsIgnoreCase, even
> though it is further down the chain.  On the other hand, longer IMAP
> commands will be slower.
>
> None of this is about big chunks of time, but the change was simple
enough,
> and is demonstrably faster.
>
> --- Noel
>


----------------------------------------------------------------------------
----


> --
> To unsubscribe, e-mail:
<mailto:james-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:james-dev-help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:james-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:james-dev-help@jakarta.apache.org>


Mime
View raw message