[fpc-pascal] For ..in GetEnumerator Allocation

Martok listbox at martoks-place.de
Wed Oct 4 14:22:28 CEST 2017

Am 04.10.2017 um 11:26 schrieb Michael Van Canneyt:
> As an alternative you can create an object enumeator. 
> It's simply allocated on the stack, and you can reset it in the enumerator
> operator.
That is by far the easiest solution (records need $modeswitch advancedrecords,
but are otherwise equivalent).

As an example, here's how I iterate over at TNodeSet returned by fcl-xml's XPath
engine: <https://pastebin.com/Zj2CLRbX>

The object is allocated on the stack and simply cleared/reset every time the
operator is executed.

Ceterum censeo b32079 esse sanandam.

More information about the fpc-pascal mailing list