Here’s a stupid scenario to illustrate a problem
Let’s say that sometimes some boolean variable “condition” is true
Now, we have some object, and one of this object’s “jobs” is to make condition false is condition is ever true.
Is there a point to doing
if(condition){
condition = false;
}
or is simply doing
condition = false;
faster? (does it change, depending on about how often “condition” is true?)
Does looking up the state of a variable take less time than simply setting it?
This is just a miniscule efficiency problem that i’ve always wondered about.
RELATED: do certain “lookups” take longer than others? Like, does checking a boolean take less time than checking an int, and does that take less time than checking if an object is some subclass? By how much?
Thanks!