We all write code like this all the time so I'm looking for THE definitive answer in terms of performance.
In NAV2017+ which is the fastest statement:
1)
IF GLSetup.GET THEN
IF GLSetup.Fieldname THEN
DoSomething := TRUE;
or
2)
IF (GLSetup.GET) AND (GLSetup.Fieldname) THEN
DoSomething := TRUE;
The 2nd one is my preference and I think it is neater but want the one that executes fastest...
0
Answers
I would care for that if we would code in assembler and counting CPU cycles, but we have to worry more about what is going on on the SQL server side.
The second check IF GLSetup.Fieldname is much much much quicker that the first, to the point that the difference between 1st and 2nd might be unmeasurable.
If you prefer the 2nd form you might get caught some day if the 2nd check is also slow.
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03