db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r171119 - /incubator/derby/code/trunk/java/tools/org/apache/derby/tools/JDBCDisplayUtil.java
Date Fri, 20 May 2005 13:58:01 GMT
Author: djd
Date: Fri May 20 06:58:00 2005
New Revision: 171119

URL: http://svn.apache.org/viewcvs?rev=171119&view=rev
Log:
Alter the way spaces are padded to a column output by JDBCDisplayUtil.
Removes the use of a second StringBuffer and avoids use of a method
not in J2ME/CDC/Foundation.

Modified:
    incubator/derby/code/trunk/java/tools/org/apache/derby/tools/JDBCDisplayUtil.java

Modified: incubator/derby/code/trunk/java/tools/org/apache/derby/tools/JDBCDisplayUtil.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/tools/org/apache/derby/tools/JDBCDisplayUtil.java?rev=171119&r1=171118&r2=171119&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/tools/org/apache/derby/tools/JDBCDisplayUtil.java (original)
+++ incubator/derby/code/trunk/java/tools/org/apache/derby/tools/JDBCDisplayUtil.java Fri
May 20 06:58:00 2005
@@ -541,24 +541,20 @@
 							0 : MINWIDTH), LocalizedResource.getInstance().getColumnDisplaySize(rsmd, i)));
 
 			if (s.length() < w) {
-				// build a string buffer to hold the whitespace
-				StringBuffer blanks = new StringBuffer(s);
-				blanks.ensureCapacity(w);
+				
+				buf.append(s);
 
 				// try to paste on big chunks of space at a time.
-				for (int k=blanks.length()+64; k<=w; k+=64)
-					blanks.append(
+				int k = w - s.length();
+				for (; k >= 64; k -= 64)
+					buf.append(
           "                                                                ");
-				for (int k=blanks.length()+16; k<=w; k+=16)
-					blanks.append("                ");
-				for (int k=blanks.length()+4; k<=w; k+=4)
-					blanks.append("    ");
-				for (int k=blanks.length(); k<w; k++)
-					blanks.append(' ');
-
-				buf.append(blanks);
-				// REMIND: could do more cleverness, like keep around
-				// past buffers to reuse...
+				for (; k >= 16; k -= 16)
+					buf.append("                ");
+				for (; k >= 4; k -= 4)
+					buf.append("    ");
+				for (; k > 0; k--)
+					buf.append(' ');
 			}
 			else if (s.length() > w)  {
 				if (w > 1) 



Mime
View raw message