[jdom-interest] Optimizing attribute lists size in built documents

Laurent Bihanic laurent.bihanic at atosorigin.com
Fri Jun 27 06:57:21 PDT 2003


The attached patch is a proposal to change the way SAXHandler adds attributes 
to elements. Instead of adding each attribute at the time, this patch uses a 
reusable ArrayList to collect all attributes and add them to the element using 
Combined with the AttributeList patch I send yesterday, it avoids resizings of 
Element.attributes that occurs when using Element.setAttribute().


                 (o o)
Laurent Bihanic                | Tel: +33 (0)1 (direct)
AtosOrigin Systems Integration |      +33 (0)1
e-Business / SC                | Fax: +33 (0)1
Les Miroirs - Bat. C           |
18, avenue d'Alsace            |
F-92926 La Defense Cedex       | E-mail: laurent.bihanic at atosorigin.com

"Microsoft isn't the answer. Microsoft is the question and the answer
  is no."

The opinions expressed are entirely my own and may not necessarily be
those of my employer.  Also, I am not now nor have I ever been a
lawyer.  My opinions are provided as-is with absolutely no warrantee of
merchantability or fitness for any particular use.  Besides, you can't
prove I typed this.  No body saw me type this.  Who says I typed this?

-------------- next part --------------
Index: SAXHandler.java
RCS file: /home/cvspublic/jdom/src/java/org/jdom/input/SAXHandler.java,v
retrieving revision 1.59
diff -r1.59 SAXHandler.java
>     /** Temporary <code>List</code> object to store element contents. */
>     private List attributeList;
>         attributeList = new ArrayList();
<             element.setAttribute(attribute);
>             attributeList.add(attribute);
>         element.setAttributes(attributeList);
>         attributeList.clear();

More information about the jdom-interest mailing list