Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: When every microsecond counts: Parsing subroutine parameters

by adamk (Chaplain)
on May 19, 2008 at 04:42 UTC ( [id://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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-03-29 08:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found