Skip to Content.
Sympa Menu

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

xom-interest AT

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Rusty Harold <elharo AT>
  • To: Janek Bogucki <janekdb AT>, xom-interest <xom-interest AT>
  • 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
Processing XML with Java (Addison-Wesley, 2002)

Archive powered by MHonArc 2.6.24.

Top of Page