Performance: many IFs vs one IF with &&'s

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.

I haven’t put in the code however there is a window in unity called “Profiler” witch tells you the preprocessing power it takes for the overall game’s scripts, rendering, the physics and more… if that script is the only one in the scene with that window and you run it, you will see a script possessing amount then go to the other example and try again…

Your two examples are completely equal. Yes “&&” will only evaluate the second operand if the first returns true otherwise it will skip the rest. Likewise “||” only evaluates the second operand when the first is false.

btw: checking a boolean for “true” can be shorten to:

if (b0 && b1 && b2)