logo       

Re: Unneeded hashtable in LazyHTMLDocument: msg#00034

java.enhydra.xmlc

Subject: Re: Unneeded hashtable in LazyHTMLDocument


Did you have a previous submission to the list? I can't find it. Anyway, no matter if this wraps up the previous one.

Richard or David. Do you guys see anything wrong with this patch? If not, I can check it in.

Jake

At 10:15 AM 11/19/2003 -0600, you wrote:
Currently in LazyHTMLDocument, which is currently using a Hashtable, the createElement method will
block on the _elementConstHTML.get() call, since hashtables are synchronized.

Since the map is read-only after it is created, it should be slightly faster to use a HashMap,
as long as you are careful not to access the map before it is finished being created.

The following diff should accomplish this, and offer at least a slight performance boost in
multithreaded situations.

This diff corrects a problem in my previous submission to this list, in that the map now can't be
accessed until it is completely initialized.

Mark Leverentz


Index: LazyHTMLDocument.java
===================================================================
RCS file: /cvsroot/xmlc/xmlc/xmlc/modules/xmlc/src/org/enhydra/xml/lazydom/html/LazyHTMLDocument.java,v
retrieving revision 1.2
diff -b -r1.2 LazyHTMLDocument.java
92c92
<
---
> import org.enhydra.apache.html.dom.*;
180,181c180,181
< private static Hashtable _elementConstHTML;
<
---
> private static HashMap _elementConstHTML;
> private static HashMap _tmpElementConstHTML;
612c612
< _elementConstHTML = new Hashtable( 63 );
---
> _tmpElementConstHTML = new HashMap( 63 );
675a676
> _elementConstHTML = _tmpElementConstHTML;
679c680
< private static void populateElementType( String tagName, String className )
---
> private static void populateElementType(String tagName, String className )
683c684
< _elementConstHTML.put( tagName, cl.getConstructor( _elemClassSigHTML ));
---
> _tmpElementConstHTML.put( tagName, cl.getConstructor( _elemClassSigHTML ));
_______________________________________________
XMLC mailing list
XMLC@xxxxxxxxxxx
http://www.enhydra.org/mailman/listinfo.cgi/xmlc


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise