ChikaYan / arduino-project

repo for COMP101P arduino project
0 stars 0 forks source link

Perform both actions in a single loop for efficiency #5

Open TimboKZ opened 6 years ago

TimboKZ commented 6 years ago

https://github.com/ChikamaYan/arduinoProject/blob/d211f89f7f1fc50a1ac16282977406b6cba046a0/processingProgram/bulletHell/bulletHell.pde#L99-L108

Doesn't make too much of a difference in this particular case but performing this in a loop usually tells the compiler/processor these actions can be executed in parallel.

ChikaYan commented 6 years ago

Sorrrrrrrry didn't notice this XD right now I'm really using it as a cloud drive and haven't paid much attention to other functions, which is a bit of waste I guess XD

ChikaYan commented 6 years ago

But the issue is removing items from list in inside the loop also causes size of list to change, thus, after removing some bullets, the bullets in the end of list will not be drawn during this call, and as a result they seem to blink a lot. Maybe I should use a temporary variable to store the size of list before loop?

ChikaYan commented 6 years ago

Then I got an IndexOutOfBoundsException XDDDDDDD