in reply to Re^2: Why is "any" slow in this case?
in thread Why is "any" slow in this case?
Output:use v5.40; my @subs; sub dosomething :prototype(&) { push @subs, $_[0]; } for (1..2) { my $x; dosomething { $x+1 } } for (1..2) { my $x; dosomething { $_+1 } } say for @subs
CODE(0x56271152c660) CODE(0x5627115470c8) CODE(0x5627115999e0) CODE(0x5627115999e0)
You can see by the addresses that Perl had to allocate a new coderef on each iteration of the first loop, but was able to reuse the coderef on the second loop.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Why is "any" slow in this case?
by ikegami (Patriarch) on Aug 05, 2025 at 01:52 UTC | |
|
Re^4: Why is "any" slow in this case?
by LanX (Saint) on Aug 04, 2025 at 21:28 UTC |