On 2012-05-21 14:12, sono...@fannullone.us wrote:
Hi Paul,

Please don't care about this until your code is running correctly but
too slowly and profiling has determined that this is the bottleneck.

        I'm curious as to why you say this.  If one way is faster than another, 
wouldn't it be better to do it that way, as long as it doesn't cause any 
problems?

        BTW, my code is running correctly.  I'm refactoring an old script.  The 
way I see it, every little bit helps. =;)

A slight sacrifice in speed is much better than a lack of clarity or problematic code, unless of course your code's speed is critical. What Paul is saying is that it's common not to focus a whole bunch on sub-millisecond performance gains like this, and when you do, it'll be because there is a problem with speed, and you'll track it down by using the available benchmarking and profiling tools.

There isn't a 'wrong' way to do what you want to do. There are benefits and drawbacks as much as there are specific reasons you'd use each.

Personally, I use shift for the most part (as I design almost all of my interfaces with the args passed in as a single hash ref. In cases I don't use that type of API, it is because the sub only takes one or two args, in which a couple of shift lines isn't much extra typing).

Steve


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to