From 513ad0fe32576e0fa268a5f585236e5272cf063d Mon Sep 17 00:00:00 2001 From: Par Winzell Date: Sun, 11 May 2008 21:44:23 +0000 Subject: [PATCH] Only do cycle checking for actual pointers -- otherwise two of the same integers or strings in sequence trigger it, which is briefly amusing but ultimately quite undesirable. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5078 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/as/com/threerings/util/StringUtil.as | 52 ++++++++++++------------ 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/src/as/com/threerings/util/StringUtil.as b/src/as/com/threerings/util/StringUtil.as index 469be646b..e3882de5a 100644 --- a/src/as/com/threerings/util/StringUtil.as +++ b/src/as/com/threerings/util/StringUtil.as @@ -283,36 +283,38 @@ public class StringUtil return String(obj); } - if (refs == null) { - refs = new Dictionary(); + if (obj is Array || Util.isPlainObject(obj)) { + if (refs == null) { + refs = new Dictionary(); - } else if (refs[obj] !== undefined) { - return "[cyclic reference]"; - } - refs[obj] = true; - - var s :String; - if (obj is Array) { - var arr :Array = (obj as Array); - s = ""; - for (var ii :int = 0; ii < arr.length; ii++) { - if (ii > 0) { - s += ", "; - } - s += (ii + ": " + toString(arr[ii], refs)); + } else if (refs[obj] !== undefined) { + return "[cyclic reference]"; } - return "Array(" + s + ")"; + refs[obj] = true; - } else if (Util.isPlainObject(obj)) { - // TODO: maybe do this for any dynamic object? (would have to use describeType) - s = ""; - for (var prop :String in obj) { - if (s.length > 0) { - s += ", "; + var s :String; + if (obj is Array) { + var arr :Array = (obj as Array); + s = ""; + for (var ii :int = 0; ii < arr.length; ii++) { + if (ii > 0) { + s += ", "; + } + s += (ii + ": " + toString(arr[ii], refs)); } - s += prop + "=>" + toString(obj[prop], refs); + return "Array(" + s + ")"; + + } else { + // TODO: maybe do this for any dynamic object? (would have to use describeType) + s = ""; + for (var prop :String in obj) { + if (s.length > 0) { + s += ", "; + } + s += prop + "=>" + toString(obj[prop], refs); + } + return "Object(" + s + ")"; } - return "Object(" + s + ")"; } else if (obj is XML) { return Util.XMLtoXMLString(obj as XML);