From 353fdcd7cf4764dc786979212800d28ee3939102 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Mon, 19 Jul 2010 17:53:59 +0000 Subject: [PATCH] I'm trying to excise uses of com.samskivert.util.Collections, which is full of some weird old stuff, much of it replaced by using Guava or newer 1.5 features. Instead of using a "sorted iterator", slap the elements in a TreeSet. Insertions are O(log n), and sorting an ArrayList would be O(n log n), so it should be pretty much the same (TreeSet probably uses more memory). Comments welcome. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6098 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/crowd/chat/client/ChatDirector.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/java/com/threerings/crowd/chat/client/ChatDirector.java b/src/java/com/threerings/crowd/chat/client/ChatDirector.java index 9adb1ded8..eb573f88a 100644 --- a/src/java/com/threerings/crowd/chat/client/ChatDirector.java +++ b/src/java/com/threerings/crowd/chat/client/ChatDirector.java @@ -33,8 +33,8 @@ import java.util.regex.Pattern; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.google.common.collect.Sets; -import com.samskivert.util.Collections; import com.samskivert.util.HashIntMap; import com.samskivert.util.ObserverList; import com.samskivert.util.ResultListener; @@ -424,12 +424,11 @@ public class ChatDirector extends BasicDirector return result; default: - String alternativeCommands = ""; - Iterator itr = Collections.getSortedIterator(possibleCommands.keySet()); - while (itr.hasNext()) { - alternativeCommands += " /" + itr.next(); + StringBuilder buf = new StringBuilder(); + for (String cmd : Sets.newTreeSet(possibleCommands.keySet())) { + buf.append(" /").append(cmd); } - return MessageBundle.tcompose("m.unspecific_command", alternativeCommands); + return MessageBundle.tcompose("m.unspecific_command", buf.toString()); } }