Which is, on average, faster - check the value then, if needed, assign, or simply assign? Or, in C++ terms:
bool b;
if(b)
b = false;
or
b = false;
Assume that the if() condition is true with 50% probability. The answer will be, most likely, highly architecture dependent - please voice your low-level considerations. Writing always dirties the cache line - right? So by avoiding a write we avoid a cache flush in 0.5 cases. But a smart enough cache might detect a trivial write and not dirty itself. But the unconditional write is always exactly one memory operation, and read-write is, on average, 1.5 operations.
Disclaimer: this is a curiosity question, not a problem I actually face.