Re: [fpc-pascal] How to avoid Copy
> On Dec 30, 2023, at 3:18 PM, Michael Van Canneyt via fpc-pascal > 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 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How to avoid Copy
On Sun, 31 Dec 2023, Amir--- via fpc-pascal wrote: On 12/31/23 02:46, Marco van de Voort via fpc-pascal wrote: Op 31/12/2023 om 04:11 schreef Amir--- via fpc-pascal: I compiled the code with `fpc -O3 -Sd -gv -g -gl ` and ran `valgrind` on it (the output is attached). It does not look like there is a big difference between the Check1 and Check2 but Check3 is about 20 times faster than the other two. I believe the issue could be resolved if we make "TCustomListWithPointers.GetPtrEnumerator" a public method. Then, one can implement the following function: I also do this (an enumerator using a pointer type) in one of my container types. It also makes assignment in the for in possible. Note though that it is not necessarily needed to switch the whole collection to use a pointer, defining a separate iterator (e.g. collection.pointeriterator) that returns an iterator instantiated for ^T. You can then select the iterator by using for element in collection.iterator do. Understand (and this is what I ended-up doing). I guess my question is that why we do not to have a PointerIterator in TList class. Because no-one thought to implement it, or no-one saw the need. Michael.___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How to avoid Copy
On 12/31/23 02:46, Marco van de Voort via fpc-pascal wrote: Op 31/12/2023 om 04:11 schreef Amir--- via fpc-pascal: I compiled the code with `fpc -O3 -Sd -gv -g -gl ` and ran `valgrind` on it (the output is attached). It does not look like there is a big difference between the Check1 and Check2 but Check3 is about 20 times faster than the other two. I believe the issue could be resolved if we make "TCustomListWithPointers.GetPtrEnumerator" a public method. Then, one can implement the following function: I also do this (an enumerator using a pointer type) in one of my container types. It also makes assignment in the for in possible. Note though that it is not necessarily needed to switch the whole collection to use a pointer, defining a separate iterator (e.g. collection.pointeriterator) that returns an iterator instantiated for ^T. You can then select the iterator by using for element in collection.iterator do. Understand (and this is what I ended-up doing). I guess my question is that why we do not to have a PointerIterator in TList class. Amir ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Daily snapshots?
Running a GUI application (like Lazarus) from a container isn't that complicated (just make sure you trust the container you run (depends on your approach) [1]): - mounting/forwarding your X server socket to the container application - remote desktop to the container via VNC or xrdp To simplify this you could use helper tools like x11docker [2]. The X server socket is Linux only but on Windows its even easier: you only need a recent WSL2 version (thus Windows 10 or newer) which comes with WSLg [3]. Then simply install Docker or Podman on your Windows host and start your GUI application in the container. [1]: https://www.baeldung.com/linux/docker-container-gui-applications [2]: https://github.com/mviereck/x11docker [3]: https://github.com/microsoft/wslg Kind regards Nico On 12/29/23 13:33, Thomas Kurz via fpc-pascal wrote: Thank you. That's what I've been looking for. Maybe the documentation at https://www.freepascal.org/docs-html/user/userse76.html could be updated regarding the new URL? @Nico: Thanks for pointing me to Docker images, but I do not have Docker support on my Windows, unfortunately. I furthermore fear that it might be complicated to use a dockerized Lazarus. Is there something special I have to consider when combining FPC-trunk with Lazarus 3.0? I'd like to replace the provided FPC 3.2.2 with the latest trunk snapshot. I guess I have to recompile all packages? Is there something else I need to do? Thank you, kind regards, Thomas - Original Message - From: Marco van de Voort via fpc-pascal To: fpc-pascal@lists.freepascal.org Sent: Friday, December 29, 2023, 12:37:54 Subject: [fpc-pascal] Daily snapshots? Op 27/12/2023 om 12:38 schreef Thomas Kurz via fpc-pascal: as it seems to take longer for the next major release, I'd appreciate if automated snapshots could be provided either daily or weekly. In the documentation, I found a link to ftp://ftp.freepascal.org/pub/fpc/snapshot/trunk/ but I cannot login. I tried with user=anynous and password=my-email-address. I don't mind the long time for the next release, but it'd help enormously to have the option to download an up-to-date nightly build :) The FTP site has been converted to http because many browsers deprecated the FTP protocol, try http://downloads.freepascal.org/fpc/snapshot/fixes/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How to avoid Copy
Op 31/12/2023 om 04:11 schreef Amir--- via fpc-pascal: I compiled the code with `fpc -O3 -Sd -gv -g -gl ` and ran `valgrind` on it (the output is attached). It does not look like there is a big difference between the Check1 and Check2 but Check3 is about 20 times faster than the other two. I believe the issue could be resolved if we make "TCustomListWithPointers.GetPtrEnumerator" a public method. Then, one can implement the following function: I also do this (an enumerator using a pointer type) in one of my container types. It also makes assignment in the for in possible. Note though that it is not necessarily needed to switch the whole collection to use a pointer, defining a separate iterator (e.g. collection.pointeriterator) that returns an iterator instantiated for ^T. You can then select the iterator by using for element in collection.iterator do. The rtl-generics collections already have multiple iterators since for maps it is possible to iterate over the keys, the values or TPair ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal