From 6dfee04a5836a4ee00e6cd255d609f888c22f4a0 Mon Sep 17 00:00:00 2001 From: Rick Giles Date: Sun, 12 Jan 2003 15:00:14 +0000 Subject: [PATCH] Modified to use more efficient TreeSet instead of ArrayList. --- .../tools/checkstyle/api/LocalizedMessages.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/api/LocalizedMessages.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/api/LocalizedMessages.java index 2f6d452e2..9bb64bdfc 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/api/LocalizedMessages.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/api/LocalizedMessages.java @@ -22,8 +22,7 @@ package com.puppycrawl.tools.checkstyle.api; // as soon as architecture has settled. At the time of writing // this class is not necessary as a part of the public api -import java.util.Collections; -import java.util.ArrayList; +import java.util.TreeSet; /** * Collection of messages. @@ -33,12 +32,11 @@ import java.util.ArrayList; public final class LocalizedMessages { /** contains the messages logged **/ - private final ArrayList mMessages = new ArrayList(); + private final TreeSet mMessages = new TreeSet(); /** @return the logged messages **/ public LocalizedMessage[] getMessages() { - Collections.sort(mMessages); return (LocalizedMessage[]) mMessages.toArray(new LocalizedMessage[mMessages.size()]); } @@ -55,9 +53,7 @@ public final class LocalizedMessages **/ public void add(LocalizedMessage aMsg) { - if (!mMessages.contains(aMsg)) { - mMessages.add(aMsg); - } + mMessages.add(aMsg); } /** @return the number of messages */