Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Always better to ...?
Message
De
26/02/2000 17:04:21
 
 
À
26/02/2000 13:50:52
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00338054
Message ID:
00338079
Vues:
18
>There are a number of little tricks. Whil Hentzen is publishing a "tricks and techniques" book soon, check hentzenwerke.com for more information. One that I remember from way back is:
>
>LOCATE (nothing after the command) is faster than GO TOP.
>
>
To be sure, this is a fine "trick", but is in some ways a classic example of using code that is fast, but cryptic and not as easy to understand and maintain. There was an excellent thread on this topic a while back; the general consensus seemed to be to s..ew the speed, keep the code readable.

Certainly there will be exceptions where the gain is great enough that you want to use it. In that case I'd suggest a Mandatory Code Block something like:
* The following command replaces GO TOP, because it may be faster:
LOCATE
>>I often wonder what is the most efficient way to code things. For instance, it seems that to alltrim(upper(fieldname)) must always be slower than upper(alltrim(fieldname)). I'm assuming in the first example, that the upper will operate on all characters in the field. In the second, upper will only act on the remaining characters. So, I always use the second method.
>>
>>How about this code...
>>IF ! USED("sometable")
>> SELECT 0
>> USE sometable
>>ELSE
>> SELECT sometable
>>ENDIF
>>
>>Wouldn't it ALWAYS be better to ...?
>>
>>IF ! USED("sometable")
>> USE sometable in 0
>>ENDIF
>>SELECT sometable
>>
>>Now oddly enough, from speed trials I did, I'm not seeing much if any difference, and either piece of code may win the race, however, less typing means less mistakes.
>>
>>Anyone care to add other little bits of code? I mean, nothing more than 10 lines.
>>
>>Seems more appropriate than some other threads up here <s>...
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform