Strogian
06-28-2005, 01:49 AM
is there EVER any point to code like this:
if (x != y)
x = y;
Maybe to avoid dirtying the cache, or something like this?
if (x != y)
x = y;
Maybe to avoid dirtying the cache, or something like this?
|
Click to See Complete Forum and Search --> : Seemingly useless code Strogian 06-28-2005, 01:49 AM is there EVER any point to code like this: if (x != y) x = y; Maybe to avoid dirtying the cache, or something like this? rock 06-28-2005, 07:48 AM I don't see a point to that code at all. If x is already equal to y, you skip the assignment. If it's not equal to y, it will be afterwards. So why test? Just assign the value and move on. Maybe somebody can make an argument that a boolean test exectues faster than an assignment, but this is as case where code readability would trump the microsecond that might be saved. SprySpectre 06-28-2005, 09:55 AM Useless. Probably does execute faster the times that x==y, but honestly how much difference could that possibly make? SharkyExtreme.com
Copyright Internet.com Inc. All Rights Reserved. |