changeset 1485:6a24c8b33d6b

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 01 May 2020 11:23:29 -0600
parents 1fa6e8ec2d53
children 2469aa31f31b
files src/goodjava/json/JsonToString.java src/luan/modules/parsers/LuanToString.java
diffstat 2 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
diff -r 1fa6e8ec2d53 -r 6a24c8b33d6b src/goodjava/json/JsonToString.java
--- a/src/goodjava/json/JsonToString.java	Sat Apr 25 11:14:25 2020 -0600
+++ b/src/goodjava/json/JsonToString.java	Fri May 01 11:23:29 2020 -0600
@@ -121,7 +121,8 @@
 		if( !list.isEmpty() ) {
 			indent(sb,indented+1);
 			toString(list.get(0),sb,indented+1);
-			for( int i=1; i<list.size(); i++ ) {
+			final int n = list.size();
+			for( int i=1; i<n; i++ ) {
 				sb.append(comma);
 				toString(list.get(i),sb,indented+1);
 			}
diff -r 1fa6e8ec2d53 -r 6a24c8b33d6b src/luan/modules/parsers/LuanToString.java
--- a/src/luan/modules/parsers/LuanToString.java	Sat Apr 25 11:14:25 2020 -0600
+++ b/src/luan/modules/parsers/LuanToString.java	Fri May 01 11:23:29 2020 -0600
@@ -61,12 +61,12 @@
 		if( !list.isEmpty() ) {
 			if( !compressed )
 				indent(sb,indented+1);
-			for( Object obj : list ) {
-				toString(obj,sb,indented+1);
-				sb.append( comma );
+			toString(list.get(0),sb,indented+1);
+			final int n = list.size();
+			for( int i=1; i<n; i++ ) {
+				sb.append(comma);
+				toString(list.get(i),sb,indented+1);
 			}
-			if( compressed )
-				sb.setLength(sb.length()-1);
 		}
 		boolean first = true;
 		for( Object obj : map.entrySet() ) {