Do you know where your variables are? | |
PerlMonks |
Re: Reminder to self: must use Memoize more often!by BrowserUk (Patriarch) |
on Jan 12, 2013 at 13:55 UTC ( [id://1013040]=note: print w/replies, xml ) | Need Help?? |
return $fib3_cache{$n} ||= do { I'd strongly recommend trading //= for ||=. Any function that can return 0, but costs to determine that, looses out as is. You can get greater benefits still for functions that take low integers as inputs by using an array instead of a hash for the cache:
And see the benefits more clearly if you do away with some of the benchmark overheads by loosing the sub wrappers (The module adds its own wrapper internally):
And finally, there's a couple more % to be had:
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
In Section
Cool Uses for Perl
|
|