Continuously writing a pin

I have a question which has bothered me for a while. Although it probably has zero implications, I thought I'd ask anyway.

Is there any harm in continually rewriting a pin with the same value?

For example, this will attempt to rewrite the output every single time:

if (digitalRead(aPin) == HIGH)
  digitalWrite(anotherPin, HIGH);
else
  digitalWrite(anotherPin, LOW);

But this will only write it when the input changes:

input = digitalRead(aPin);

if(oldInput != input)
{
  if (input == HIGH)
    digitalWrite(anotherPin, HIGH);
  else
    digitalWrite(anotherPin, LOW);
    
  oldInput = input;
}

And for the pedants, I realise these are only code snippets without context but hopefully they get the point of my question across...

There is no harm in writing the same value to the pin over and over. I can't cite any documentation, but I have seen it done.

groundfungus:
I have seen it done.

Yep I have done it plenty of times but it always makes me feel slightly uneasy since I don't know which way is "better".

Why would it be a problem?

.

LarryD:
Why would it be a problem?

I guess I just wasn't sure if writing to the same register over and over might result in additional "wear" in a similar fashion to EEPROM.

You are OK doing it.

.

might result in additional "wear" in a similar fashion to EEPROM.

Not at all.

The problem here is it is a waste of time.
Consider updating the output pin on switch changes only, this would speed up sketch execution.

.

Yeah I guess that is true. Although in a simple sketch I imagine it's not going to have much of a noticeable effect.

Thanks very much for the answers. I was half expecting to get hammered for asking such a silly question but I can finally sleep soundly now :stuck_out_tongue:

I can finally sleep soundly now

Consider that Donald Trump is president of the U.S.