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: PR libgcj/21140 -vs- 4.0


I'm checking this in on the 4.0 branch.

Due to compatibility constraints we can't use the fix that is already
on the trunk.  Instead it seemed simplest to just disable caching on
the branch.  This is less efficient, but at least it is correct.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	PR libgcj/21140:
	* java/nio/charset/Charset.java (encode, decode): Don't cache.

Index: java/nio/charset/Charset.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/charset/Charset.java,v
retrieving revision 1.9
diff -u -r1.9 Charset.java
--- java/nio/charset/Charset.java 19 Feb 2005 09:10:38 -0000 1.9
+++ java/nio/charset/Charset.java 17 May 2005 01:08:49 -0000
@@ -1,5 +1,5 @@
 /* Charset.java -- 
-   Copyright (C) 2002, 2004  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -227,21 +227,10 @@
   {
     try
       {
-        // NB: This implementation serializes different threads calling
-        // Charset.encode(), a potential performance problem.  It might
-        // be better to remove the cache, or use ThreadLocal to cache on
-        // a per-thread basis.
-        synchronized (Charset.class)
-          {
-            if (cachedEncoder == null)
-              {
-                cachedEncoder = newEncoder ()
-                  .onMalformedInput (CodingErrorAction.REPLACE)
-                  .onUnmappableCharacter (CodingErrorAction.REPLACE);
-              }
-
-            return cachedEncoder.encode (cb);
-          }
+	CharsetEncoder enc = newEncoder ()
+	  .onMalformedInput (CodingErrorAction.REPLACE)
+	  .onUnmappableCharacter (CodingErrorAction.REPLACE);
+	return enc.encode (cb);
       }
     catch (CharacterCodingException e)
       {
@@ -258,21 +247,10 @@
   {
     try
       {
-        // NB: This implementation serializes different threads calling
-        // Charset.decode(), a potential performance problem.  It might
-        // be better to remove the cache, or use ThreadLocal to cache on
-        // a per-thread basis.
-        synchronized (Charset.class)
-          {
-            if (cachedDecoder == null)
-              {
-                cachedDecoder = newDecoder ()
-                  .onMalformedInput (CodingErrorAction.REPLACE)
-                  .onUnmappableCharacter (CodingErrorAction.REPLACE);
-              }
-
-            return cachedDecoder.decode (bb);
-          }
+	CharsetDecoder dec = newDecoder ()
+	  .onMalformedInput (CodingErrorAction.REPLACE)
+	  .onUnmappableCharacter (CodingErrorAction.REPLACE);
+	return dec.decode (bb);
       }
     catch (CharacterCodingException e)
       {


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