[kaffe] CVS kaffe (dalibor): Resynced with GNU Classpath: StringBuffer optmization
Kaffe CVS
cvs-commits at kaffe.org
Sun Mar 7 09:14:04 PST 2004
PatchSet 4487
Date: 2004/03/07 17:10:52
Author: dalibor
Branch: HEAD
Tag: (none)
Log:
Resynced with GNU Classpath: StringBuffer optmization
2004-03-07 Dalibor Topic <robilad at kaffe.org>
Resynced with GNU Classpath
2004-02-27 Anthony Green <green at redhat.com>
* java/lang/StringBuffer.java: No need to NULL out remainder of
buffer since ensureCapacity_unsynchronized will have done this for
us.
Members:
ChangeLog:1.2067->1.2068
libraries/javalib/java/lang/StringBuffer.java:1.24->1.25
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2067 kaffe/ChangeLog:1.2068
--- kaffe/ChangeLog:1.2067 Sun Mar 7 16:45:35 2004
+++ kaffe/ChangeLog Sun Mar 7 17:10:52 2004
@@ -2,6 +2,16 @@
Resynced with GNU Classpath
+ 2004-02-27 Anthony Green <green at redhat.com>
+
+ * java/lang/StringBuffer.java: No need to NULL out remainder of
+ buffer since ensureCapacity_unsynchronized will have done this for
+ us.
+
+2004-03-07 Dalibor Topic <robilad at kaffe.org>
+
+ Resynced with GNU Classpath
+
2004-03-03 Michael Koch <konqueror at gmx.de>
* java/io/File.java: Reformated.
Index: kaffe/libraries/javalib/java/lang/StringBuffer.java
diff -u kaffe/libraries/javalib/java/lang/StringBuffer.java:1.24 kaffe/libraries/javalib/java/lang/StringBuffer.java:1.25
--- kaffe/libraries/javalib/java/lang/StringBuffer.java:1.24 Sat Oct 25 18:30:23 2003
+++ kaffe/libraries/javalib/java/lang/StringBuffer.java Sun Mar 7 17:10:53 2004
@@ -1,5 +1,6 @@
/* StringBuffer.java -- Growable strings
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
+ Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -205,10 +206,26 @@
if (newLength < 0)
throw new StringIndexOutOfBoundsException(newLength);
+ int valueLength = value.length;
+
+ /* Always call ensureCapacity_unsynchronized in order to preserve
+ copy-on-write semantics. */
ensureCapacity_unsynchronized(newLength);
- while (count < newLength)
- value[count++] = '\0';
- count = newLength;
+
+ if (newLength < valueLength)
+ {
+ /* If the StringBuffer's value just grew, then we know that
+ value is newly allocated and the region between count and
+ newLength is filled with '\0'. */
+ count = newLength;
+ }
+ else
+ {
+ /* The StringBuffer's value doesn't need to grow. However,
+ we should clear out any cruft that may exist. */
+ while (count < newLength)
+ value[count++] = '\0';
+ }
}
/**
More information about the kaffe
mailing list