Which logic would be better or effecient:
IF VAR-A = FALSE
MOVE VAR-C TO VAR-B
ELSE
MOVE VAR-A TO VAR-B
END-IF
or
MOVE VAR-A TO VAR-B
IF VAR-A = FALSE
MOVE VAR-C TO VAR-B
END-IF
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In general, either is fine and you should leave the optimization to your compiler.
However, since source code is written for humans to understand what prior programmers have created, I would say:
Use this form if either condition is likely to occur:
But in a case where the IF condition is a very rare kind of thing and the unqualified MOVE is the 99% condition, try this approach, as it highlights the fact that VAR-A=FALSE is a rare and special thing:
Just my NSH $0.02. Either works well as long as you remember that the compiler will take most any crap you feed it, your primary concern is the next human that must read your program.