Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DO CASE vs IF
Message
De
28/12/2000 12:30:56
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00457199
Message ID:
00457402
Vues:
25
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform