0 Members and 3 Guests are viewing this topic.
If A If B Do stuff EndEnd
If A If B Do stuff EndEndor...If A!=0 and (B!=0) Do stuffEnd
If A and B Do stuffEnd
Keeping in mind what calcdude84se pointed out about A and B, if either A or B will sometimes be non-boolean values (anything besides 0 and 1), you want to use the two separate if statements. If they will always be booleans, however, compare the following two blocks of code:Code: [Select]If A If B Do stuff EndEndA is false: 34 t-statesA is true: 68 t-statesCode: [Select]If A and B Do stuffEnd66 t-statesThe second one is only faster if A will be true at least 16/17 of the time.
Quote from: Runer112 on December 23, 2010, 01:12:00 pmKeeping in mind what calcdude84se pointed out about A and B, if either A or B will sometimes be non-boolean values (anything besides 0 and 1), you want to use the two separate if statements. If they will always be booleans, however, compare the following two blocks of code:Code: [Select]If A If B Do stuff EndEndA is false: 34 t-statesA is true: 68 t-statesCode: [Select]If A and B Do stuffEnd66 t-statesThe second one is only faster if A will be true at least 16/17 of the time.Thats excellent data! So what that means is that even if A is true 94% of the time, its still worth it to make the change to two if statements So as a general rule, the best thing to do is to use two different If statements if you are going for absolute speed. Unless A is only false like once in every 9000th cycle
:If B: If A: do stuff: End:End
{====______}
{=========_}
If A__op__ If B__op__ Do stuff EndEnd
If A__op__ and (B__op__) Do stuffEnd