Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Possible ArrayList optimization

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
  • To: Janek Bogucki <janekdb AT yahoo.co.uk>, xom-interest <xom-interest AT lists.ibiblio.org>
  • Cc:
  • Subject: Re: [XOM-interest] Possible ArrayList optimization
  • Date: Mon, 12 May 2003 22:14:09 -0400

At 10:05 PM +0100 5/11/03, Janek Bogucki wrote:

Is there any reason why an invocation of ArrayList.trimToSize (), after the array has had all
items added to it, would be inappropriate? This would minimise the storage cost.

I hadn't thought of that. How expensive is trimToSize()? Probably O(1) I expect, and you might be able to make that up by not having to constantly grow the arrays as you build the document. Just start them fairly large, and then chop it down when you're finished. I'll try it out and see what it does to the numbers.
--

Elliotte Rusty Harold
elharo AT metalab.unc.edu
Processing XML with Java (Addison-Wesley, 2002)
http://www.cafeconleche.org/books/xmljava
http://www.amazon.com/exec/obidos/ISBN%3D0201771861/cafeaulaitA




Archive powered by MHonArc 2.6.24.

Top of Page