Synchronization often shows up near the very top of gcj-compiled
benchmarks. It turns out that, for benchmarks I've run, ~50% of the
synchronization calls come from reading property files with
StringBuffer. This should all go away if we use StringBuilder instead.
Ok?
2005-10-19 Anthony Green <[EMAIL PROTECTED]>
* java/util/Properties.java (load, store, formatForOutput): Use
StringBuilder instead of StringBuffer.
Index: java/util/Properties.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Properties.java,v
retrieving revision 1.33
diff -u -r1.33 Properties.java
--- java/util/Properties.java 16 Oct 2005 23:25:56 -0000 1.33
+++ java/util/Properties.java 19 Oct 2005 19:17:18 -0000
@@ -209,7 +209,7 @@
// The characters up to the next Whitespace, ':', or '='
// describe the key. But look for escape sequences.
- StringBuffer key = new StringBuffer();
+ StringBuilder key = new StringBuilder();
while (pos < line.length()
&& ! Character.isWhitespace(c = line.charAt(pos++))
&& c != '=' && c != ':')
@@ -275,7 +275,7 @@
pos++;
}
- StringBuffer element = new StringBuffer(line.length() - pos);
+ StringBuilder element = new StringBuilder(line.length() - pos);
while (pos < line.length())
{
c = line.charAt(pos++);
@@ -395,7 +395,7 @@
Iterator iter = entrySet ().iterator ();
int i = size ();
- StringBuffer s = new StringBuffer (); // Reuse the same buffer.
+ StringBuilder s = new StringBuilder (); // Reuse the same buffer.
while (--i >= 0)
{
Map.Entry entry = (Map.Entry) iter.next ();
@@ -538,7 +538,7 @@
* leading spaces must be escaped for the value
* @see #store(OutputStream, String)
*/
- private void formatForOutput(String str, StringBuffer buffer, boolean key)
+ private void formatForOutput(String str, StringBuilder buffer, boolean key)
{
if (key)
{
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches