| Back to top |
Forgive the nitpick-y nature of this optimization, as I am eternally grateful for this script's usefulness, however I suggest searching for all occurrences of the following type of FOR loop:
:: Code ::
//os tester for ( $i = 0; $i < count( $a_os ); $i++ ) in which the count() function is being used as the guard condition, and replacing each occurrence with something akin to the following: :: Code ::
//os tester $osCount = count($a_os); for ( $i = 0; $i < $osCount; $i++ ) By caching the the number of elements in the array, loop execution can be improved up to 50% by not having to call count() repeatedly. This was gleaned from section 28.2, Optimizing Loops, in Core PHP Programming, by Leon Atkinson and Zeev Suraski. -Chris |
|||||
|
techAdmin
Back to top
Status: Site Admin Joined: 26 Sep 2003 Posts: 747 Location: East Coast, West Coast? I know it's one of them. |
ah, very nice, that's a habit i have, I didn't realize it would count it each time. No problem with the nitpicking, that's what makes code get better, thanks for letting me know about that aspect of the loop, I always assumed that was counted one time, then used.
Hardly nitpicking, a lot of time was spent on that trying to get it somewhat optimized over time. <check new versions, all loops are now pre counted rather than counting arrays.> |
|||||
|
All times are GMT - 8 Hours
|
||||||
Contact Us
Hosting: Pair Networks: 0.043
Forum Software © 2001–2006 phpBB
techForum Style © 2003–2006 techpatterns.com
info
Hosting: Pair Networks: 0.043
Forum Software © 2001–2006 phpBB
techForum Style © 2003–2006 techpatterns.com
info