IMHO, it certainly is - maintainability is an important part of good coding, and readable, well commented, well laid out code is a big part of that. In 6 months time could you (or someone else) look at the first example and quickly see what was going on? Or if you get an error, quickly see where it was coming from?
Just my 2 cents.
Just a something something...
| [reply] |
When I need to speed up code I go looking for nested hash references as in your example. It's my believe the cost of creating a new variable is small(er) compared to the cost of looking up the value of a nested reference. If the same value is referenced more than once, it's worth creating a variable to skip as much dereferencing as you can.
The fact that it's more readable is just a bonus.
| [reply] |
Wow, I was surprised to discover this. It is really faster with temporary variable.
Thanks everyone for sharing your thoughts.
| [reply] |
Unless it causes a [significant ] performance hit you should always go with the more readable version. It's depressing that you even had to ask a question with such an obvious answer!
Elda Taluta; Sarks Sark; Ark Arks
| [reply] |
Well, I was not sure about it - I'm new to Catalyst. First variant could be catalyst-way or something. So I decided to ask you guys.
| [reply] |
| [reply] |