Help - Checking+Setting Better Than Setting?

I have started working on android games and i know for a fact that android devices have a pretty limited CPU compared to PC’s CPU, and my question comes to this:
Is checking if something is the same(and if isnt, set it), FASTER, than having it constantly changed to that value, even if it is already it?

Example:
if(transform.scale != neededScale)
transform.scale = neededScale;
or just
transform.scale = neededScale;

I hope someone could explain me what is faster and why

There is no way you’ll notice the difference unless you’re working on something weaker than the N-Gage.

That being said, the comparrison is probably super-fast (one check for each coordinate), while setting the value might set off a chain-reaction of recalculations. I have seen setting the position to itself causing the scene graph to update in editor time, so I guess it’s possible. In that case, the check would be faster, but again, not something you’d notice.

To put it like this - if setting the value was in any way slow, Unity would already be doing the comparrison in the background.

In the general case where you’re not talking about transform.scale, but any value, this depends on if setting the value has any side-effects. If it’s just a field, it’ll probably just be faster to set it. If something has to be updated as a result, do the check.

But don’t take my word for it, run a profiler. Do something like this:

void Update() {
    if (Input.GetKeyDown(KeyCode.A)) {
        Vector3 scale = transform.localScale;
        for (int i = 0; i < 100000; i++) {
            transform.localScale = scale;
        }
    }

    if (Input.GetKeyDown(KeyCode.B)) {
        Vector3 scale = transform.localScale;
        for (int i = 0; i < 100000; i++) {
            if (transform.localScale != scale)
                transform.localScale = scale;
        }
    }
}

open the profiler, and compare pressing A to pressing B. Simple as that.

Many thanks Baste!
Ill try it out now.(As soon as the blacksmith demo downloads haha)

Update:
Weirdly enough, only the setting up the scale is almost as twice as fast than the checking it also!