[Swift-commit] r4772 - trunk/src/org/griphyn/vdl/karajan/lib/swiftscript

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Tue Jul 5 15:36:35 CDT 2011


Author: hategan
Date: 2011-07-05 15:36:35 -0500 (Tue, 05 Jul 2011)
New Revision: 4772

Modified:
   trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java
Log:
use StringBuilder instead of StringBuffer and fix toString

Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java	2011-07-05 20:23:23 UTC (rev 4771)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java	2011-07-05 20:36:35 UTC (rev 4772)
@@ -59,7 +59,7 @@
 
 		AbstractDataNode[] args = VDLFunction.waitForAllVargs(stack);
 
-		StringBuffer buf = new StringBuffer();
+		StringBuilder buf = new StringBuilder();
 		buf.append("SwiftScript trace: ");
 		for (int i = 0; i < args.length; i++) {
 			DSHandle handle = args[i];
@@ -74,7 +74,7 @@
 		return null;
 	}
 
-	private void prettyPrint(StringBuffer buf, DSHandle h) {
+	private void prettyPrint(StringBuilder buf, DSHandle h) {
 	    Object o = h.getValue();
 	    if (o == null) {
 	        buf.append(h);
@@ -363,7 +363,14 @@
 	throws ExecutionException {
 	    Object input = PA_INPUT.getValue(stack);
 	    DSHandle handle = new RootDataNode(Types.STRING);
-	    handle.setValue(String.valueOf(input));
+	    if (input instanceof DSHandle) {
+	        StringBuilder sb = new StringBuilder();
+	        prettyPrint(sb, (DSHandle) input);
+	        handle.setValue(sb.toString());
+	    }
+	    else {
+	        handle.setValue(String.valueOf(input));
+	    }
 	    handle.closeShallow();
 	    return handle;
 	}




More information about the Swift-commit mailing list