Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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.

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 about the Monastery: (4)
As of 2016-06-30 00:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (388 votes). Check out past polls.