Preformance impact from writing code in Update()

I am very interested in knowing how much of a difference it makes performance-wise to put the code in the update-function, versus changing the variables outside of the update-function.

Take this code for example:

    void Update()
    {
        transform.position = otherObjectsScript.transform.position//Moves the object to another object
        if (x == 10)//If x becomes 10 it is reset.
        {
            x = 0;
        }
    }

All of the code above could be moved to other functions in the script, because the position only has to be updated occasionally when the player clicks. If the player has not done anything, the transform.position-line will simply set the object’s position to the position that it is already at, so updating it at this time changes nothing.
Also, the variable x will only change during certain player actions, so the check that resets x could be done only in these circumstances instead of the update-function.

So, the question is: Would it significantly (in the long run) improve the preformance of the game to make these kinds changes outside of Update() as described above, or does Unity make this more or less the same (by detecting that the variables have not been changed, and thus not process the lines)?

There is probably no optimisation for identical values (it’s faster to copy the new value and destroy the current value than it is to check the current value against the new value and then copy the new value).

If you know for sure that the only time it is changed is when the player presses a button, it would be more efficient to update things at that time. For instance:

void Update() {
	// if player presses 'A', update properties and variables
	if (Input.GetKeyDown(KeyCode.A))
	{
		// other position is changed
		otherObjectsScript.transform.position += new Vector3(0,0,1);

		transform.position = otherObjectsScript.transform.position;

		x++; // x is changed
		if (x == 10)
		{
			x = 0;
		}
	}
}

Side notes: I think it’s worth keeping the line transform.position = otherObjectsScript.transform.position outside of the if (Input...) block, because the other GameObject’s position may be changed by other scripts not relating to the player input. Also, when synchronizing transforms with another GameObject each frame, I would put that line in LateUpdate(), not regular Update(), to make sure the other GameObject is updated before this one.)