[richfaces-svn-commits] JBoss Rich Faces SVN: r2088 - trunk/framework/impl/src/main/java/org/ajax4jsf/io.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Mon Aug 6 20:47:52 EDT 2007


Author: ishabalov
Date: 2007-08-06 20:47:52 -0400 (Mon, 06 Aug 2007)
New Revision: 2088

Modified:
   trunk/framework/impl/src/main/java/org/ajax4jsf/io/CharBuffer.java
Log:
http://jira.jboss.org/jira/browse/RF-549


Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/io/CharBuffer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/io/CharBuffer.java	2007-08-06 20:44:27 UTC (rev 2087)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/io/CharBuffer.java	2007-08-07 00:47:52 UTC (rev 2088)
@@ -40,7 +40,7 @@
 	 * Length of char array.
 	 */
 	private int cacheSize;
-	
+	private static int MIN_CACHE_SIZE = 64;
 	/**
 	 * number of characters stored in the array.
 	 */
@@ -51,8 +51,12 @@
 	 * @param cacheSize length of char array
 	 */	
 	public CharBuffer(int cacheSize) {
-		this.cacheSize = cacheSize;
-		chars = new char[cacheSize];
+		if (cacheSize<MIN_CACHE_SIZE) {
+			this.cacheSize = MIN_CACHE_SIZE;
+		} else {
+			this.cacheSize = cacheSize;
+		}
+		chars = new char[this.cacheSize];
 		usedSize = 0;
 	}
 	
@@ -63,12 +67,16 @@
 	public CharBuffer(char[] chars) {
 		this.chars = chars;
 		usedSize = chars.length;
-		cacheSize = usedSize;
+		if (usedSize<MIN_CACHE_SIZE) {
+			this.cacheSize = MIN_CACHE_SIZE;
+		} else {
+			this.cacheSize = usedSize;
+		}
 	}
 	
 	/**
 	 * Appends character to array chars if there are unfilled positions in it.
-	 * Otherwize creates next link in the chain, and appends the character to it.
+	 * Otherwise creates next link in the chain, and appends the character to it.
 	 * @param c
 	 * @return instance of CharBuffer to which character was appended.
 	 */	
@@ -89,13 +97,13 @@
 	
 	/**
 	 * Appends segment of a char array to array if there are unfilled positions in it.
-	 * Otherwize creates next link in the chain, and appends data to it.
+	 * Otherwise creates next link in the chain, and appends data to it.
 	 * @param c
 	 * @return instance of CharBuffer to which char array was appended.
 	 */	
 	public CharBuffer append(char[] cs, int off, int len) {
 		if(next != null) {
-			return append(cs, off, len);
+			return next.append(cs, off, len);
 		}
 		if(len + usedSize <= cacheSize) {
 			System.arraycopy(cs, off, chars, usedSize, len);




More information about the richfaces-svn-commits mailing list