Or with half the allocations: https://go.dev/play/p/LmtNdR-hfWY
I can't get it down to 1 allocation, which should be the theoretical
minimum, as I can't get the compiler to move the closure and the state
being closed over into one allocation.

On Fri, 16 Aug 2024 at 11:43, Axel Wagner <axel.wagner...@googlemail.com>
wrote:

> You can also use reflect to get non-restartable map-iterators. It has some
> additional setup cost, but I don't think it's *a lot* and after that it
> should be relatively cheap.
> https://go.dev/play/p/vUec8AYhFPa
>
> On Fri, 16 Aug 2024 at 09:34, Costanza, Pascal <pascal.costa...@intel.com>
> wrote:
>
>> I haven’t double-checked, but according to the documentation of the
>> standard library, this should be possible: You can get an iterator over a
>> map from the maps package, and then convert it into a pull-style iterator
>> using the iter package.
>>
>> > On 16 Aug 2024, at 00:47, 'Dan Kortschak' via golang-nuts <
>> golang-nuts@googlegroups.com> wrote:
>> >
>> > On Thu, 2024-08-15 at 22:32 +0000, Costanza, Pascal wrote:
>> >> I believe the indices in your examples are updated in the wrong
>> >> place. The following seems to do what I believe you
>> >> expect: https://go.dev/play/p/U2YQM3fOz98
>> >
>> > Thanks for clearing that up; that's very useful to know. This means the
>> > issue is only whether map iterators will ever be exposed. I'm (sadly)
>> > guessing that this will not happen.
>> >
>> > Dan
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "golang-nuts" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an email to golang-nuts+unsubscr...@googlegroups.com.
>> > To view this discussion on the web visit
>> https://groups.google.com/d/msgid/golang-nuts/75d4b45c94122309c011f60e37903ad86eb6238e.camel%40kortschak.io
>> .
>>
>> Intel Corporation nv/sa
>> Froissartstraat 95
>> 1040 Etterbeek
>> RPR (Brussel) 0415.497.718.
>> Citibank, Brussels, account BE52 5701 0312 5509
>>
>> This e-mail and any attachments may contain confidential material for the
>> sole use of the intended recipient(s). Any review or distribution by others
>> is strictly prohibited. If you are not the intended recipient, please
>> contact the sender and delete all copies.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to golang-nuts+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/golang-nuts/9894AABA-166B-4A9F-A04A-5C394A1F524A%40intel.com
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAEkBMfEbHZKwuHX%3DxzLKJYPpuPGQKZYsJ0xbR%2BdWypREODQWyw%40mail.gmail.com.

Reply via email to