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 equi
> On Oct 4, 2017, at 10:03 PM, Michael Van Canneyt
> wrote:
>
> Newinstance allocates the memory for a new instance of the class.
> By default this is GetMem(instanceSize).
So you override the class method Newinstance in the enumerator class and return
the same block of memory? Then when I ov
> On Oct 4, 2017, at 5:19 PM, Marco van de Voort wrote:
>
> Yup, or a record. See e.g. http://www.stack.nl/~marcov/lightcontainers.zip
This seems like the simplest more efficient method. Does FPC just know it’s a
record internally and not try to dealloc it? GetEnumerator seems like a magic
m
On Wed, 4 Oct 2017 15:41:27 +0700
Ryan Joseph wrote:
> As I understand the for..in loop GetEnumerator method is expected to create a
> new object each time it’s called and FPC destroys it later when the loos is
> finished. Can I retain the enumerator and just reset it in-between calls? I’d
> l
On Wed, 4 Oct 2017, Ryan Joseph wrote:
On Oct 4, 2017, at 4:26 PM, Michael Van Canneyt wrote:
You can do so by overriding the newinstance and it's sister method of
your enumerator class.
Can you explain how this works or give an example? Not sure how these gets
around the problem of all
> On Oct 4, 2017, at 4:26 PM, Michael Van Canneyt
> wrote:
>
> You can do so by overriding the newinstance and it's sister method of
> your enumerator class.
Can you explain how this works or give an example? Not sure how these gets
around the problem of alloc/dealloc for each iterator.
Rega
On 2017-10-04 09:41, Ryan Joseph wrote:
I’d like to remove all these alloc/deallocs so I can use for..in more
efficiently in tight loops.
I've had the same requirement, and also needed that functionality before
the for..in syntax existed in FPC. Take a look at my Iterator interface
and imple
In our previous episode, Michael Van Canneyt said:
> 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.
Yup, or a record. See e.g. http://www.stack.nl/~marcov/lightcontainers.zip
On Wed, 4 Oct 2017, Ryan Joseph wrote:
As I understand the for..in loop GetEnumerator method is expected to create a new object each time it’s called
and FPC destroys it later when the loos is finished. Can I retain the enumerator and just reset it in-between calls?
I’d like to remove all the
As I understand the for..in loop GetEnumerator method is expected to create a
new object each time it’s called and FPC destroys it later when the loos is
finished. Can I retain the enumerator and just reset it in-between calls? I’d
like to remove all these alloc/deallocs so I can use for..in mor
10 matches
Mail list logo