|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-02-18 07:30 UTC] krakjoe@php.net
-Package: Feature/Change Request
+Package: *General Issues
[2015-02-18 07:32 UTC] krakjoe@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: krakjoe
[2015-02-18 07:32 UTC] krakjoe@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 02:00:01 2025 UTC |
Description: ------------ 10/13/03 12:14 PM Hidetomo Katsura: apache_mod_php: move stuff out of the loop as much as possible in this example, CFArrayGetCount() gets executed every time it loops: for ( index = 0; index < CFArrayGetCount( array ); ++index ) { value = CFArrayGetValueAtIndex( array, index ); // do something with value } _if_ the count of array does not change in the loop, CFArrayGetCount() only needs to be called once outside of the loop: count = CFArrayGetCount( array ); for ( index = 0; index < count; ++index ) { value = CFArrayGetValueAtIndex( array, index ); // do something with value } % cd ~rc/Updates/Panther/Panther7B85/Projects/ apache_mod_php % grep -rns "for.*;.*Count(.*;" . ------------ apache_mod_php -------------- ./php/ext/fbsql/php_fbsql.c:3512: for (i=0; i<fbaCount(asInfo->infoLines); i++) { NOTE: this bug is not about major performance improvement, and this bug should be the lowest priority. we all know this is a micro optimization and not going to make Mac OS X 100x faster if you just move the "count" function out of the loop. but the point is that you should never write a loop with unnecessary code in it in the first place. this is just a reminder based on something "srcsgrep" found. please fix whenever you have a chance to modify the listed files. thanks.