You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2007/08/22 06:19:32 UTC

svn commit: r568405 - /xerces/java/trunk/src/org/apache/xerces/impl/XMLEntityScanner.java

Author: mrglavas
Date: Tue Aug 21 21:19:29 2007
New Revision: 568405

URL: http://svn.apache.org/viewvc?rev=568405&view=rev
Log:
JIRA Issue #1264:
http://issues.apache.org/jira/browse/XERCESJ-1264

As part of its normal control flow the XMLEntityScanner will throw an EOFException when it reaches the end of the document. For small documents, this can take up as much as 20-25% of the total execution time in the parser but could be even more than that depending on the depth of the call stack at the point where parse() is called. To eliminate most of this cost we now cache the exception and avoid filling in its stack trace (thus also saving some memory).

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

Modified: xerces/java/trunk/src/org/apache/xerces/impl/XMLEntityScanner.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/XMLEntityScanner.java?rev=568405&r1=568404&r2=568405&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/XMLEntityScanner.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/XMLEntityScanner.java Tue Aug 21 21:19:29 2007
@@ -45,6 +45,13 @@
     // constants
     private static final boolean DEBUG_ENCODINGS = false;
     private static final boolean DEBUG_BUFFER = false;
+    
+    private static final EOFException END_OF_DOCUMENT_ENTITY = new EOFException() {
+        private static final long serialVersionUID = 980337771224675268L;
+        public Throwable fillInStackTrace() {
+            return this;
+        }
+    };
 
     //
     // Data
@@ -1762,7 +1769,7 @@
             if (changeEntity) {
                 fEntityManager.endEntity();
                 if (fCurrentEntity == null) {
-                    throw new EOFException();
+                    throw END_OF_DOCUMENT_ENTITY;
                 }
                 // handle the trailing edges
                 if (fCurrentEntity.position == fCurrentEntity.count) {
@@ -1779,7 +1786,6 @@
         return entityChanged;
 
     } // load(int, boolean):boolean
-
 
 } // class XMLEntityScanner
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org