On 2013-09-02 13:34:18 +0000, "qznc" <[email protected]> said:
On Saturday, 31 August 2013 at 18:53:42 UTC, Michel Fortin wrote:
For instance, Tango's SaxParser is based on its PullParser. This design
requires the use a dynamic array to maintain a stack of opened
elements. While not a huge performance hit, you don't need that if you
use recursion, which you can do with my implementation. You can do that
even though you can also use it as a pull tokenizer[^1] when needed
(recursion is optional on a token-by-token basis).
Recursion means you use the call stack instead of stack object on the heap.
Be careful about nesting deepness. There are XML documents out there
with thousands and more nested elements. With recursion on a 32bit
machine you might get a stack overflow, but a heap-stack could handle a
million nested elements.
Good point about caring for pathological cases.
--
Michel Fortin
[email protected]
http://michelf.ca