Author Topic: For( Loop Slowdown Update  (Read 2109 times)

0 Members and 1 Guest are viewing this topic.

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
For( Loop Slowdown Update
« on: November 11, 2010, 12:50:19 am »
Most of us know about the For( slow down issues. If you don't, I'll explain it really fast.

Basically if you have a piece of code that does something like this:

Code: [Select]
For(A,1,9
If fPart(A/2
\Do something.\
End

When ever that conditional is false it will cause a slow down for the loop, which is annoying. However there are three ways to fix this. First, you can simply put a parenthesis at the end of the For( loop line (so it'd become For(A,1,9)), second, there is a OS fix by BrandonW that apparently fixes it and, three, you can make the If statement an If:Then statement.

Now to the point of this thread. I know I have been curious about this question for quite a while, as I'm sure a few other people. The question is basically: What about if you have nested For( loops? Do you have to close both of them?

Well to be honest we still don't have a definitive answer to this but the current thinking, by a lot of people is that you only have to close the nested one. So for example:

Code: (Took 44 seconds.) [Select]
For(A,0,94
For(B,0,62
If not(AB
Pxl-On(B,A
End
End

could become:

Code: (Took 37 seconds.) [Select]
For(A,0,94
For(B,0,62)
If not(AB
Pxl-On(B,A
End
End

I just did a quick test with just this example and it seems to have checked out however this hasn't been concretely proven yet. Just thought I'd let everyone know :)

Courtesy of DJ:
Quote
In some rare cases, not closing the parhentesis of a for( loop under such circumnstances can cause the calc to slow down by about 1.5 until the ON key is pressed or the program is exited.
« Last Edit: November 11, 2010, 12:59:34 am by meishe91 »
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: For( Loop Slowdown Update
« Reply #1 on: November 11, 2010, 12:56:21 am »
Interesting. Could you add that in some rare cases, not closing the parhentesis of a for( loop under such circumnstances can cause the calc to slow down by about 1.5 until the ON key is pressed or the program is exited? I had that happen while coding Illusiat 13, but I don't know how I triggered that.

BrandonW released a patch fixing those For loop issues, but it's good to keep that trick in mind since most people don't have his patch installed.

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: For( Loop Slowdown Update
« Reply #2 on: November 11, 2010, 01:00:17 am »
I don't know a whole lot about that rare situation you've encountered so I just copied and pasted what you had said :P Thanks.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)