Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: When every microsecond counts: Parsing subroutine parameters

by adamk (Chaplain)
on May 19, 2008 at 04:42 UTC ( #687281=note: print w/ replies, xml ) Need Help??


in reply to When every microsecond counts: Parsing subroutine parameters

I think there might be a small mistake in one of your examples.

The entire point of doing "my %args = @_" is that you then don't HAVE to extract them to their own variables. Granted, you pay incrementally per invocation of $args{...} but you don't pay for the ones you don't use. And if you only use a param once, it's cheaper than allocating it to a variable.

So the slice and allocation you have there is probably superfluous

Named params is also a good way to support subclassing, because you don't have to co-ordinate with child classes.

You just $self->SUPER::method(@_) or $self->SUPER::method(%args);

I'll also note that, for a number of position params two or smaller, it's faster to have two separate "my $var = shift;" calls than one "my ($var, $var) = @_;" call.


Comment on Re: When every microsecond counts: Parsing subroutine parameters

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2015-07-28 04:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (252 votes), past polls