All,
Attached is a patch to the POP3Handler.java code that rolls in the String.equalsIgnoreCase change that Noel suggested. All other previously made changes were left intact. Attached is the source and diff. As always, comments, criticisms, and questions are welcome. --Peter > -----Original Message----- > From: Noel J. Bergman [mailto:[EMAIL PROTECTED]] > Sent: Saturday, August 03, 2002 8:59 PM > To: James-Dev Mailing List > Subject: String.equalsIgnoreCase Considered Evil :-) > > There are many places in James where we have lengthy sets of comparisons > of > an unknown string value to a known string value. These are many of these > of > the form: > > string.equalsIgnoreCase(<literal>) > > This use is terribly inefficient. Each and every call iterates through > both > the string and the literal, uppercasing both as it compares them. > > Please, as you are working on code (Peter will apply these to POP3Handler > and SMTPHandler), if you see this pattern, please change it to: > > string = string.to[Upper|Lower]Case(); // chose depending upon your > literals > > string.equals(<literal>) > > For example, in SMTPHandler and POP3Handler: > > String command = commandRaw.trim(); > becomes > String command = commandRaw.trim().toUpperCase(); > > and the test for "USER" (for example) becomes: > > if (command.equals("USER")) ... > > Actually, I believe that we should add a command-map model to the > handlers, > but that's a seperate issue for a separate thread. The change proposed in > this e-mail is simple. > > --- Noel > > P.S. Brownie points for whomever recognizes the origin of the subject > header > > > -- > To unsubscribe, e-mail: <mailto:james-dev- > [EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:james-dev- > [EMAIL PROTECTED]>
POP3Handler.java
Description: java/
POP3Handler.java.diff
Description: Binary data
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
