How the system checks whether if statements are matched or not?
For example #1:
void Update ()
{
bool b0 = false;
bool b1 = true;
bool b2 = true;
if (b0 == true)
{
if (b1 == true)
{
if (b2 == true)
{
}
}
}
}
For example #2:
void Update ()
{
bool b0 = false;
bool b1 = true;
bool b2 = true;
if (b0 == true && b1 == true && b2 == true)
{
}
}
In example #1 the system will check b0, it’s not true, so it’ll skip everything. So it’s just one check per frame.
In example #2 the system will check b0, then see it’s not true and it’ll understand, that there’re only &&'s and it’ll skip the rest? Or it’ll waste its resources on checking the rest? Thus 3 checks per frame, even if b0 is false, making example #1 better for performance? +example #2 also has &&'s which may be require more resources for the system to perceive it as a formula “a && b && d”, while example #1 has simple one component one after another.