Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Why doesn't perl optimize this?

by ikegami (Pope)
on Jun 04, 2013 at 04:35 UTC ( #1036886=note: print w/ replies, xml ) Need Help??


in reply to Why doesn't perl optimize this?

Note that It can't safely be optimised that way at compile-time. Consider

sub f { my @a; tie @a, 'SomeClass' if $_[0]; g(\@a); return [ @a ]; }

If @a or one of its elements is magical, if an element of @a overloads =, or if the REFCNT of @a or one of its elements is greater than one, then the optimisation can't be applied.

So if f's first argument is true, then the optimisation can't be applied. If g saved the reference to @a, then the optimisation can't be applied. etc.

We're talking about a massive amount of resources to avoid a rare annoyance. Make a perlcritic rule instead.


Comment on Re: Why doesn't perl optimize this?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1036886]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (21)
As of 2014-07-23 15:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (145 votes), past polls