RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo
| From: | Andrea Giammarchi | Date: | Tue, 06 Oct 2009 22:59:54 +0000 |
| Subject: | RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-298706@lists.php.net to get a copy of this message | ||
> So while we can debate computing considerations of today, tomorrow
> those will be less important. That was the point I was making. Why
> not focus on things that make significant difference and let the
> insignificant fade into history.
I tendentiously focus on all things able to make, all together, even more significant difference.
Some micro-optimization, used as common code style, can make the entire application or the specific
performance critical task, possible, even with an embed language as PHP is.
++$i is not different, from my point of view, from a code where each sequential push is performed
via array_push($arr, $value) rather than $arr[] = $value;
Same is for all those loop such
for($i = 0; $i < count($staticStack); $i++);
for me alien, since I've always done
for($i = 0, $length = count($staticStack); $i < $length; ++$i);
or, even better, a core performed loop when I need values
foreach($staticStack as $value);
these are just examples, code style, whatever you want, and I'll never change my style unless
there is a valid reason and some bench able to demonstrate I am wrong. I guess it's just a
matter of point of views, but I cannot suggest slower practice cause Moore said tomorrow that CPU
will strike the millisecond, 'cause on micro benchmarks, we can go faster, and that's it.
Regards
_________________________________________________________________
Windows Live: Keep your friends up to date with what you do online.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_1:092010