Should List.map2, etc. be taking all of the input lists as owned arguments? Couldn't that often lead to an unnecessary copy of the entire list? Technically, List.map2 only needs to copy the elements in the list if they need to be modified instead of copying the entire list to get ownership.
Side note, as they are written currently, I think they free all the elements in the list, but leak the list itself.
Taking the list as owned means you can reuse the allocation though, right? For the common case you’re mapping from one type to the same, or the elements can be transmuted to the same size
Yeah, but in map2 it takes both with ownership. Map3 takes all 3 as owned, etc
I guess we could check all of them for potential reuse, just feels strange to me
Also, we probably should add in reuse. I don't think we have it currently. At least based on the zig bitcode.
We have reuse as a static optimization, though yeah not oportunistic at RT I guess
Ah. Compile time deals with it. Makes sense.
So that means owning all 3 is intended behaviour for map3 then? Cause it enables more compile time reuse?
I think @Folkert de Vries knows best
Last updated: Jul 06 2025 at 12:14 UTC