[PHP] Re: Assignment (Was Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)

2008-12-24 Thread tedd
At 11:06 AM +1100 12/24/08, Clancy wrote: On Tue, 23 Dec 2008 10:25:13 -0500, tedd.sperl...@gmail.com (tedd) wrote: >Two things: 1. One statement, one line. 2. The code between the two examples is different; produces different results; and thus is rather pointless in making a definitive >com

[PHP] Re: Assignment (Was Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)

2008-12-23 Thread Clancy
On Tue, 23 Dec 2008 10:25:13 -0500, tedd.sperl...@gmail.com (tedd) wrote: >At 9:10 AM +1100 12/23/08, Clancy wrote: >>Schlossnagle (in "Advanced PHP Programming") advises: >> >>$i = 0; while ($i < $j) >> { >> >> ++$i; >> } >> >>rather than: >> >>$i = 0; while ($i < $j)

[PHP] Assignment (Was Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)

2008-12-23 Thread tedd
At 9:10 AM +1100 12/23/08, Clancy wrote: Schlossnagle (in "Advanced PHP Programming") advises: $i = 0; while ($i < $j) { ++$i; } rather than: $i = 0; while ($i < $j) { ... $i++; } as the former apparently uses less m

Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)

2008-12-23 Thread Clancy
On Mon, 22 Dec 2008 22:40:58 -0800, larstor...@gmail.com ("Lars Torben Wilson") wrote: >Well, in all fairness, it *is* faster--but you'll only notice the >difference in extremely tight and long-running loops (try it ;) ). As >long as you know why you're using it and what the side effects are, it

Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)

2008-12-23 Thread German Geek
oops, yes of course lol Tim-Hinnerk Heuer http://www.ihostnz.com On Tue, Dec 23, 2008 at 7:43 PM, Lars Torben Wilson wrote: > 2008/12/22 German Geek : > > agree, ++$i wont save u nething, it just means that the variable is > > incremented after it is used: > > You meant ". . .before it is used:

Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)

2008-12-22 Thread Nathan Nobbe
On Mon, Dec 22, 2008 at 11:43 PM, Lars Torben Wilson wrote: > 2008/12/22 German Geek : > > agree, ++$i wont save u nething, it just means that the variable is > > incremented after it is used: > > You meant ". . .before it is used:", right? i hope so, coming from an individual who likes to optim

Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)

2008-12-22 Thread Lars Torben Wilson
2008/12/22 German Geek : > agree, ++$i wont save u nething, it just means that the variable is > incremented after it is used: You meant ". . .before it is used:", right? Torben > $i = 0; > while ($i < 4) echo $i++; > > will output > 0123 > > while > > $i = 0; > while ($i < 4) echo ++$i; > > wi

Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)

2008-12-22 Thread Lars Torben Wilson
2008/12/22 Nathan Nobbe : > On Mon, Dec 22, 2008 at 3:10 PM, Clancy wrote: > >> On Mon, 22 Dec 2008 10:20:09 +1100, dmag...@gmail.com (Chris) wrote: >> >> >I'd call this a micro-optimization. If changing this causes that much of >> >a difference in your script, wow - you're way ahead

Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)

2008-12-22 Thread German Geek
agree, ++$i wont save u nething, it just means that the variable is incremented after it is used: $i = 0; while ($i < 4) echo $i++; will output 0123 while $i = 0; while ($i < 4) echo ++$i; will output 1234 Tim-Hinnerk Heuer http://www.ihostnz.com On Tue, Dec 23, 2008 at 7:25 PM, Nathan Nob

Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)

2008-12-22 Thread Nathan Nobbe
On Mon, Dec 22, 2008 at 3:10 PM, Clancy wrote: > On Mon, 22 Dec 2008 10:20:09 +1100, dmag...@gmail.com (Chris) wrote: > > >I'd call this a micro-optimization. If changing this causes that much of > >a difference in your script, wow - you're way ahead of the rest of us. > > Schlossnag

[PHP] More microptimisation (Was Re: [PHP] Variable as an index)

2008-12-22 Thread Clancy
On Mon, 22 Dec 2008 10:20:09 +1100, dmag...@gmail.com (Chris) wrote: >I'd call this a micro-optimization. If changing this causes that much of >a difference in your script, wow - you're way ahead of the rest of us. Schlossnagle (in "Advanced PHP Programming") advises: $i = 0; while