N
nick
Guest
I have been programming since 2001 first using VB and now using PHP
But in every language I have seen some functions and some loops are far slower then the others which can produce the same results.
Let me list some of them and if you have some ideas about others then please list them too.
First of all.
A Switch is faster then multiple IF's
Then comes the Loops
Ordered from fastest to slowest ones.
FOR Loop
While Loop
Do-While Loop
Foreach Loop
Now comes the use of arrays rather then defining number of variables inside some loop.
For example if you have a loop from 1 to 100 and you are assigning values to 100 varibales then use array here. and then walk through that array with help of some other loop if needed or directly access its value at some point in the code flow.
But in every language I have seen some functions and some loops are far slower then the others which can produce the same results.
Let me list some of them and if you have some ideas about others then please list them too.
First of all.
A Switch is faster then multiple IF's
Then comes the Loops
Ordered from fastest to slowest ones.
FOR Loop
While Loop
Do-While Loop
Foreach Loop
Now comes the use of arrays rather then defining number of variables inside some loop.
For example if you have a loop from 1 to 100 and you are assigning values to 100 varibales then use array here. and then walk through that array with help of some other loop if needed or directly access its value at some point in the code flow.