Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Three cosmetic patches

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: jcowan AT reutershealth.com
  • To: Wolfgang Hoschek <whoschek AT lbl.gov>
  • Cc: Elliotte Rusty Harold <elharo AT metalab.unc.edu>, xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Three cosmetic patches
  • Date: Tue, 10 Feb 2004 15:48:10 -0500

Wolfgang Hoschek scripsit:

> I presume you mean the third patch about iteration vs. recursion.
> Nope, i haven't measured it. But what i gathered from CS studies and
> benchmarks years ago is that iteration is always faster than recursion
> because it avoids function calls, stack allocations and deallocations,
> processor register state switching, allows better compiler optimizations
> because it increases optimization scope, better register allocation,
> etc.

In addition, recursion is dangerous in Java in library routines that recurse
over user-supplied data, because the per-thread stack is of fixed size,
is typically set globally, and no recovery is possible if it overflows.

For that reason, my old DOMParser code (a DOM Level 1 analogue of XOM's
SAXConverter) used iteration instead of recursion, despite some criticism
I got for doing so.

--
John Cowan www.reutershealth.com www.ccil.org/~cowan
jcowan AT reutershealth.com
Arise, you prisoners of Windows / Arise, you slaves of Redmond, Wash,
The day and hour soon are coming / When all the IT folks say "Gosh!"
It isn't from a clever lawsuit / That Windowsland will finally fall,
But thousands writing open source code / Like mice who nibble through a wall.




Archive powered by MHonArc 2.6.24.

Top of Page