how to optimize IF condition
-
I have following line of code:
if(a==Z|| b==Z|| c==Z|| d==Z|| e==Z|| f==Z|| g==Z) { . . . }
can this be written in a better way ? p.s all the variables are of type enumsHow about:
if (a <= Z && Z <= g)
...Of course, trying to one-up the optimizer is usually a lost cause.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
I have following line of code:
if(a==Z|| b==Z|| c==Z|| d==Z|| e==Z|| f==Z|| g==Z) { . . . }
can this be written in a better way ? p.s all the variables are of type enumsIs Z a enumeration value or a variable? If they are all variables, you really can't do much without making assumptions about ordering for the values.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac