This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: FYI: new StringBuffer fix


I was overzealous in removing "unnecessary" code from the new
StringBuffer, and I removed something that actually was required.
This causes a failure in some situations.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* gnu/gcj/runtime/StringBuffer.java
	(ensureCapacity_unsynchronized): Ensure we always get at least
	`minimumCapacity' characters in new buffer.

Index: gnu/gcj/runtime/StringBuffer.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/gcj/runtime/StringBuffer.java,v
retrieving revision 1.1
diff -u -r1.1 StringBuffer.java
--- gnu/gcj/runtime/StringBuffer.java 2001/12/11 18:01:39 1.1
+++ gnu/gcj/runtime/StringBuffer.java 2001/12/12 16:48:40
@@ -130,7 +130,7 @@
   {
     if (minimumCapacity > value.length)
       {
-	minimumCapacity = value.length * 2 + 2;
+	minimumCapacity = Math.max (minimumCapacity, value.length * 2 + 2);
 	char[] nb = new char[minimumCapacity];
 	System.arraycopy(value, 0, nb, 0, count);
 	value = nb;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]