Refactor LazyDOMQueryResultIterator
Rework the logic to keep minimum stack allocations. Whereas we used
stack for keeping the decision state and traverse all entries, here
we keep an explicit stack with state.
We mutate the state using a "simple" sstateful dispatch, where we
are are carefully peeling the various possibilities. This logic is
one large method due to 'current' being manipulated and non-local
returns.
This improves test case performance by more than a factor-of-two,
easily beating linear search by a wide margin.
For clarity we have two classes of Frames, one dealing with MapNode's
children and the other one taking care of all the other nodes. While
this might cause bimorphic invocation of Frame.hasNext(), the overall
effect on clarity is immense.
We also change match() a bit, to take predicates, as it is all that
it should be interested in.
JIRA: MDSAL-610
Change-Id: I7136c6297cc66832539d1bb3d9f653968eb7bdb1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>