> On 22 Nov 2017, at 19:31, Timo Paulssen via RT <perl6-bugs-follo...@perl.org> > wrote: > On Mon, 20 Nov 2017 12:13:47 -0800, ronaldxs wrote: >> What about a native perl6 range loop? Couldn't there be some way for >> Perl 6 / Rakudo to generate code competitive on a small range with the >> "native-loop" example? >> >> perl6 -e ' >> { >> my int ($a, $one, $three) = (42, 1, 3); >> for ^10_000_000 { $a += $one + $a%$three }; >> say now - ENTER now; >> say $a >> }' > > This code will actually be turned into a `loop` loop by the optimizer at > compile time. If you type the block to have a signature of `-> int $_ --> > Nil` it'll get faster.
So, is there a reason we don’t do this on all ^10000 type loops that don’t expect the return value to be used? Because in my benchmarks, this is 3x as fast! With only 25% of the allocations, so a lot less GC churn! > The optimizer doesn't do anything like that for the `^$limit` case, however. That feels more that it needs a smarter spesh to me? Liz