Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DO CASE vs IF
Message
From
28/12/2000 12:30:56
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00457199
Message ID:
00457402
Views:
24
Dennis:

> Visual FoxPro provides us with a three constructs for branching program
> execution – the standard IF…ELSE…ENDIF, the DO CASE and the IIF() . What
> is the benefit (in terms of performance) of one over the other? The most
> obvious statement to use, the DO CASE, is in every situation significantly
> slower, while the most unreadable and hardest to construct (the IIF()) was
> always the quickest to execute."

A couple of obeservations:

(1) IIF is a special case of IF..ELSE..ENDIF where the only instruction is an immediate assignment. It's _almost always_ possible to write a more efficient Asssembly routine for such specialized cases.

(2) DO CASE..ENDCASE is not the same as nested IF..ELSE..ENDIF statements because DO CASE..ENDCASE only counts once towards the nested level (nest IF..ELSE..ENDIF 65 times and it will fail, write 150 CASE and it will work). DO CASE..ENDCASE suffers a performance hit because it is not simply translated the same as nested IF..ELSE..ENDIF statements when compiled.

Daniel
Previous
Reply
Map
View

Click here to load this message in the networking platform