From decb56970cb561180fb221bdd1188f4f8c96e09b Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Mon, 9 Aug 2010 18:37:54 +0000 Subject: [PATCH] Use the Maps builder method. Assign the DEFAULT_MAP if we unstream an empty map, too. Comment DEFAULT_MAP. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6107 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/as/com/threerings/util/StreamableHashMap.as | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/as/com/threerings/util/StreamableHashMap.as b/src/as/com/threerings/util/StreamableHashMap.as index 55591c1d6..884b21403 100644 --- a/src/as/com/threerings/util/StreamableHashMap.as +++ b/src/as/com/threerings/util/StreamableHashMap.as @@ -27,8 +27,6 @@ import com.threerings.io.Streamable; import com.threerings.util.Maps; import com.threerings.util.maps.ForwardingMap; -import com.threerings.util.maps.HashMap; -import com.threerings.util.maps.ImmutableMap; /** * A Map that can be sent over the wire, bearing in mind that all keys and values must @@ -78,10 +76,12 @@ public class StreamableHashMap extends ForwardingMap } } else { - _source = Maps.newMapOf(String); // hope for the best + _source = DEFAULT_MAP; } } - protected static const DEFAULT_MAP :Map = new ImmutableMap(new HashMap()); + /** Used when we don't know the key class. Typically if a map is unstreamed it is + * read-only anyway, so this will work for empty maps that are unstreamed. */ + protected static const DEFAULT_MAP :Map = Maps.newBuilder(Object).makeImmutable().build(); } }