[fpc-pascal] How to avoid Copy
Hairy Pixels
genericptr at gmail.com
Mon Jan 1 00:31:43 CET 2024
> On Dec 30, 2023, at 3:18 PM, Michael Van Canneyt via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
>
> And try to avoid "for r in data" because it will create a copy for each element
> in the list.
This seems more like bad compiler design than anything. From the users perspective a for loop is a read-only operation and shouldn't be copying anything. I know it's how the enumerator thing is done but that may have been a bad design from the start or needs some extra optimization somewhere.
For OP I would just kill the for-in loop in favor of a normal for-do loop and be done with the problem.
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list