sboag 00/10/17 12:28:30
Modified: java/src/org/apache/xml/serialize/transition HTMLdtd.java
Log:
Optimize entity lookup for first 256 characters.
Revision Changes Path
1.2 +15 -4
xml-xalan/java/src/org/apache/xml/serialize/transition/HTMLdtd.java
Index: HTMLdtd.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/serialize/transition/HTMLdtd.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HTMLdtd.java 2000/10/02 02:43:12 1.1
+++ HTMLdtd.java 2000/10/17 19:28:29 1.2
@@ -81,7 +81,7 @@
* first time any of these methods is called for fast and efficient access.
*
*
- * @version $Revision: 1.1 $ $Date: 2000/10/02 02:43:12 $
+ * @version $Revision: 1.2 $ $Date: 2000/10/17 19:28:29 $
* @author <a href="mailto:[EMAIL PROTECTED]">Assaf Arkin</a>
*/
public final class HTMLdtd
@@ -336,7 +336,7 @@
{
Object value;
- initialize();
+ // initialize();
value = _byName.get( name );
if ( value != null && value instanceof Character )
return ( (Character) value ).charValue();
@@ -355,9 +355,12 @@
*/
public static String fromChar( char value )
{
+ if((value < S_NOESCAPETABLESIZE) && ('\0' == m_noEscapeChars[value]))
+ return null;
+
String name;
- initialize();
+ // initialize();
name = (String) _byChar.get( String.valueOf( value ) );
if ( name == null )
return null;
@@ -365,6 +368,8 @@
return name;
}
+ private static final int S_NOESCAPETABLESIZE = 256;
+ private static char[] m_noEscapeChars = new char[S_NOESCAPETABLESIZE];
/**
* Initialize upon first access. Will load all the HTML character
references
@@ -386,6 +391,8 @@
if ( _byName != null )
return;
try {
+ for(int i = 0; i < S_NOESCAPETABLESIZE; i++)
+ m_noEscapeChars[i] = '\0';
_byName = new Hashtable();
_byChar = new Hashtable();
is = HTMLdtd.class.getResourceAsStream( ENTITIES_RESOURCE );
@@ -408,7 +415,11 @@
if ( index > 0 )
value = value.substring( 0, index );
code = Integer.parseInt( value );
- defineEntity( name, (char) code );
+ if(code < S_NOESCAPETABLESIZE)
+ {
+ m_noEscapeChars[code] = 'e';
+ }
+ defineEntity( name, (char) code );
}
}
line = reader.readLine();