Generally I agree but there are some circumstances where it will make a
difference. Counting down to zero would be fairly small I agree but other
similar optimisations can have a big difference.
- Hide quoted text -
- Show quoted text -
I've never done any testing but I've seen (old code mostly) check
stuff like "if(test1 > x && test1 < x) {...}" instead of just
"if(test1 == x) {...}". I've also seen a person "optimize" their
screen pixel color search algorithm (AutoIt language) by breaking the
color their looking for into 3 parts and then doing a huge if statment
like below
if(red < chk && red > chk && blue > chk && blue < chk && green < chk
&& green > chk) {...} instead of just if(color == chk) {...}.
It made sence to me when reading it at the time i thought (the check
is running for millions of pixels and fails 99% of the time, so if
failing then fast type of thing), but I never really knew for sure.
Basically I have a question very simular to the first; is doing this
type of thing (== to < && >) faster for C# (C# is what I mainly use
now)? Or just an urban myth of the past? Its always been something
in the back of my mind that I've been curious about but never got
around to actually testing myself.
NB