Author: mrglavas
Date: Tue Jul 25 21:18:13 2006
New Revision: 425603

URL: http://svn.apache.org/viewvc?rev=425603&view=rev
Log:
Minor performance improvement. If we know the encoding is UTF-8 return
the optimized UTF-8 reader immediately. The same goes for ISO-8859-1.

Modified:
    xerces/java/trunk/src/org/apache/xerces/impl/XMLEntityManager.java

Modified: xerces/java/trunk/src/org/apache/xerces/impl/XMLEntityManager.java
URL: 
http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/XMLEntityManager.java?rev=425603&r1=425602&r2=425603&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/XMLEntityManager.java 
(original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/XMLEntityManager.java Tue Jul 
25 21:18:13 2006
@@ -2003,9 +2003,12 @@
     protected Reader createReader(InputStream inputStream, String encoding, 
Boolean isBigEndian)
         throws IOException {
 
-        // normalize encoding name
-        if (encoding == null) {
-            encoding = "UTF-8";
+        // if the encoding is UTF-8 use the optimized UTF-8 reader
+        if (encoding == "UTF-8" || encoding == null) {
+            if (DEBUG_ENCODINGS) {
+                System.out.println("$$$ creating UTF8Reader");
+            }
+            return new UTF8Reader(inputStream, fBufferSize, 
fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN), 
fErrorReporter.getLocale());
         }
 
         // try to use an optimized reader
@@ -2014,7 +2017,7 @@
             if (DEBUG_ENCODINGS) {
                 System.out.println("$$$ creating UTF8Reader");
             }
-            return new UTF8Reader(inputStream, fBufferSize, 
fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN), 
fErrorReporter.getLocale() );
+            return new UTF8Reader(inputStream, fBufferSize, 
fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN), 
fErrorReporter.getLocale());
         }
         if(ENCODING.equals("ISO-10646-UCS-4")) {
             if(isBigEndian != null) {
@@ -2063,7 +2066,10 @@
             //       invalid UTF-8 sequence to be detected. This is only
             //       important when continue-after-fatal-error is turned
             //       on. -Ac
-            encoding = "ISO-8859-1";
+            if (DEBUG_ENCODINGS) {
+                System.out.println("$$$ creating Latin1Reader");
+            }
+            return new Latin1Reader(inputStream, fBufferSize);
         }
 
         // try to use a Java reader
@@ -2077,7 +2083,10 @@
                                        new Object[] { encoding },
                                        XMLErrorReporter.SEVERITY_FATAL_ERROR);
                 // see comment above.
-                javaEncoding = "ISO8859_1";
+                if (DEBUG_ENCODINGS) {
+                    System.out.println("$$$ creating Latin1Reader");
+                }
+                return new Latin1Reader(inputStream, fBufferSize);
             }
         }
         else if (javaEncoding.equals("ASCII")) {



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to