dgraham 2003/08/19 16:26:28 Modified: src/share/org/apache/struts/action ActionMessages.java Log: Moved Comparator implementation to a constant variable to avoid creating a new object on each call. Also fixed size() javadoc. Revision Changes Path 1.11 +18 -13 jakarta-struts/src/share/org/apache/struts/action/ActionMessages.java Index: ActionMessages.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionMessages.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- ActionMessages.java 12 Aug 2003 00:31:46 -0000 1.10 +++ ActionMessages.java 19 Aug 2003 23:26:28 -0000 1.11 @@ -91,6 +91,16 @@ * @since Struts 1.1 */ public class ActionMessages implements Serializable { + + /** + * Compares ActionMessageItem objects. + */ + private static final Comparator actionItemComparator = new Comparator() { + public int compare(Object o1, Object o2) { + return ((ActionMessageItem) o1).getOrder() + - ((ActionMessageItem) o2).getOrder(); + } + }; // ----------------------------------------------------- Manifest Constants @@ -219,7 +229,7 @@ public Iterator get() { if (messages.isEmpty()) { - return (Collections.EMPTY_LIST.iterator()); + return Collections.EMPTY_LIST.iterator(); } ArrayList results = new ArrayList(); @@ -231,11 +241,7 @@ // Sort ActionMessageItems based on the initial order the // property/key was added to ActionMessages. - Collections.sort(actionItems, new Comparator() { - public int compare(Object o1, Object o2) { - return ((ActionMessageItem) o1).getOrder() - ((ActionMessageItem) o2).getOrder(); - } - }); + Collections.sort(actionItems, actionItemComparator); for (Iterator i = actionItems.iterator(); i.hasNext();) { ActionMessageItem ami = (ActionMessageItem) i.next(); @@ -245,8 +251,7 @@ } } - return (results.iterator()); - + return results.iterator(); } /** @@ -283,7 +288,7 @@ /** * Return the number of messages recorded for all properties (including * global messages). <strong>NOTE</strong> - it is more efficient to call - * <code>empty()</code> if all you care about is whether or not there are + * <code>isEmpty()</code> if all you care about is whether or not there are * any messages at all. */ public int size() {
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]