You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by sa...@apache.org on 2002/08/23 22:38:26 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/impl Constants.java XMLEntityManager.java
sandygao 2002/08/23 13:38:26
Modified: java/src/org/apache/xerces/impl Constants.java
XMLEntityManager.java
Log:
Performance changes (thanks to Neeraj's changes to the jaxp branch):
1. A new property for the input buffer size. The value is an Integer. It's better
to use a larger buffer for big input files, and smaller one for small files.
2. Use different buffer size for internal and external entity, because internal
ones are usually of smaller size.
3. The rewindable input stream doesn't need to be that big. In most cases,
it only need to hold the <?xml ... ?> decl, and 64 bytes seem to be sufficient
for many ecodings.
Revision Changes Path
1.19 +4 -1 xml-xerces/java/src/org/apache/xerces/impl/Constants.java
Index: Constants.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Constants.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- Constants.java 17 Jul 2002 00:28:11 -0000 1.18
+++ Constants.java 23 Aug 2002 20:38:26 -0000 1.19
@@ -261,6 +261,9 @@
/** Entity manager property ("internal/entity-manager"). */
public static final String ENTITY_MANAGER_PROPERTY = "internal/entity-manager";
+ /** Input buffer size property ("input-buffer-size"). */
+ public static final String BUFFER_SIZE_PROPERTY = "input-buffer-size";
+
/** Entity resolver property ("internal/entity-resolver"). */
public static final String ENTITY_RESOLVER_PROPERTY = "internal/entity-resolver";
1.37 +22 -5 xml-xerces/java/src/org/apache/xerces/impl/XMLEntityManager.java
Index: XMLEntityManager.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLEntityManager.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- XMLEntityManager.java 13 Aug 2002 22:57:08 -0000 1.36
+++ XMLEntityManager.java 23 Aug 2002 20:38:26 -0000 1.37
@@ -132,6 +132,9 @@
/** Default buffer size before we've finished with the XMLDecl: */
public static final int DEFAULT_XMLDECL_BUFFER_SIZE = 64;
+ /** Default internal entity buffer size (1024). */
+ public static final int DEFAULT_INTERNAL_BUFFER_SIZE = 1024;
+
// feature identifiers
/** Feature identifier: validation. */
@@ -172,6 +175,10 @@
protected static final String VALIDATION_MANAGER =
Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATION_MANAGER_PROPERTY;
+ /** property identifier: buffer size. */
+ protected static final String BUFFER_SIZE =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.BUFFER_SIZE_PROPERTY;
+
// recognized features and properties
/** Recognized features. */
@@ -189,6 +196,7 @@
ERROR_REPORTER,
ENTITY_RESOLVER,
VALIDATION_MANAGER,
+ BUFFER_SIZE
};
private static final String XMLEntity = "[xml]".intern();
@@ -276,8 +284,9 @@
// settings
/**
- * Buffer size. This feature does not have a feature identifier, yet.
- * Should it?
+ * Buffer size. We get this value from a property. The default size
+ * is used if the input buffer size property is not specified.
+ * REVISIT: do we need a property for internal entity buffer size?
*/
protected int fBufferSize = DEFAULT_BUFFER_SIZE;
@@ -977,6 +986,7 @@
catch (XMLConfigurationException e) {
fValidationManager = null;
}
+
// initialize state
fStandalone = false;
fEntities.clear();
@@ -1093,6 +1103,12 @@
fEntityResolver = (XMLEntityResolver)value;
return;
}
+ if (property.equals(Constants.BUFFER_SIZE_PROPERTY)) {
+ Integer bufferSize = (Integer)value;
+ if (bufferSize != null && bufferSize.intValue() > 0) {
+ fBufferSize = bufferSize.intValue();
+ }
+ }
}
} // setProperty(String,Object)
@@ -1795,7 +1811,7 @@
// buffer
/** Character buffer. */
- public char[] ch = new char[fBufferSize];
+ public char[] ch = null;
/** Position in character buffer. */
public int position;
@@ -1823,6 +1839,7 @@
this.literal = literal;
this.mayReadChunks = mayReadChunks;
this.isExternal = isExternal;
+ this.ch = new char[isExternal ? fBufferSize : DEFAULT_INTERNAL_BUFFER_SIZE];
} // <init>(StringXMLResourceIdentifier,InputStream,Reader,String,boolean, boolean)
//
@@ -3316,7 +3333,7 @@
private int fMark;
public RewindableInputStream(InputStream is) {
- fData = new byte[DEFAULT_BUFFER_SIZE];
+ fData = new byte[DEFAULT_XMLDECL_BUFFER_SIZE];
fInputStream = is;
fStartOffset = 0;
fEndOffset = -1;
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org