Optimization question

Is one of these code examples faster?

if (a == something  b == somethingelse) {
    do stuff
}
if (a == something) {
    if (b == somethingelse) {
        do stuff
    }
}

No.

However if test b is quicker than test a to perform then put b before a.

Also for example, (this may have changed now) but this

if (a == b) {
 //do something
}

is sower than

if (a.x == b.x  a.y == b.y  a.z == b.z) {
 //do something
}

assuming a and b are vectors, hopefully that has been fixed now though.

If you want to know the answer to silly questions like this, time them yourself - repeat both operation a million times (do something inside the loop though or it might be optimized away), check the before and after times on each. Faster than posting in an internet forum and waiting for responses. And if the result is interesting, other people will want to know about it!