Re: Bug #13317 Updated: Optimizing Bug for 'sizeof' function
| From: | John Lim | Date: | Sun, 16 Sep 2001 05:31:51 +0000 |
| Subject: | Re: Bug #13317 Updated: Optimizing Bug for 'sizeof' function | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-66040@lists.php.net to get a copy of this message | ||
Out of curiosity, would the Zend Optimizer optimize this for loop?
Does it recognize sizeof( ) as an invariant?
Probably not as the size of an object can change within the for-loop.
Bye, John
<joey@php.net> wrote in message
news:20010915200519.28395.qmail@php2.chek.com...
> ID: 13317
> Updated by: joey
> Reported By: mladdens@eunet.yu
> Old Status: Open
> Status: Bogus
> Bug Type: Performance problem
> Operating System: Unix/Linux
> PHP Version: 4.0.6
> New Comment:
>
> But that is what you have ASKED it to do.
> This is the way that for() should behave. Not a bug.
>
> Previous Comments:
> ------------------------------------------------------------------------
>
> [2001-09-15 10:56:28] mladdens@eunet.yu
>
> There is a huge diference in speed with these two approaches:
>
> $file=file("file.txt");
>
> 1.
> for($i=0;$i<sizeof($file);$i++)
> ...
>
> 2.
> $file_size=sizeof($file);
> for($i=0;$i<$file_size;$i++)
> ...
>
> The second approach is much more faster, because the first seems to
calculate the 'sizeof' in every iteration.
>
> ------------------------------------------------------------------------
>
>
>
> Edit this bug report at
> http://bugs.php.net/?id=13317&edit=1
>