Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Argument starter - The roots of all evil
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00938079
Message ID:
00940468
Vues:
45
>>>>>First I'd store ALEN() in a var, to save reevaluating it every time thro' the loop :),
>>>>
>>>>No need. FOR loops evaluate their bounds only once.
>>>>
>>>>Tamar
>>>
>>>Ah, good. Didn't know that. Still, it's good practice so to do generally, no?
>>>You would do that for the do while loop tho'?
>>
>>Yep, because DO loops evaluate their bounds each time through. I assume that one of the reasons FOR loops are faster than DO loops (last time I tested, which was VFP 7, an empty FOR loop was about 10 times faster than an empty DO WHILE) is that the FOR loop evaluates the end boundary only once and stores that value.
>>
>>Tamar
>
>So how do they compare when such as ALEN() has been evaluated first before the do loop? I'd never considered this but, for a large list/array look-up (not ever had to do too many of them tho'), it might appear, otherwise, (gulp) that a, dare I say it, EXIT in a for loop might just be acceptable. THERE I'VE SAID IT!!!! :-)
>
Terry,

I'm disappointed! :-)

Rather than a FOR loop, if you're searching an ordered array or list, a DO WHILE construct for a binary search is faster than a sequenctial search. That's what both a FOR loop or ASCAN() would use.
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform