(This might be more of a common C question)
I want to test several conditions in an IF-sentence
if(variable) { // fastest check
if(register) { // a bit slower
if(read_peripheral) { // very slow check
// [do something]
}
}
}
It seems obvious that I want to start with the fastest check, and move on to the slower ones afterwards, potentially avoiding to check them if the above was false.
Now since I need to check quite a few conditions, I'd like to know if the following is the same, or if all conditions will be evaluated prior to making a decision?
if(variable && register && read_peripheral) {
// [do something]
}