Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: how to improve the performance of a perl program

by tobyink (Canon)
on Aug 05, 2013 at 16:52 UTC ( [id://1047934]=note: print w/replies, xml ) Need Help??


in reply to how to improve the performance of a perl program

Re point #1, the idea is to avoid, say:

if ($thing->position->x == 0 and $thing->position->y == 0) { ...; }

... which calls $thing->position twice, with something like this:

my $pos = $thing->position; if ($pos->x == 0 and $pos->y == 0) { ...; }

... which only calls it once.

package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-26 03:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found