Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
UDF transmutation
Message
De
13/08/2015 01:23:34
Walter Meester
HoogkarspelPays-Bas
 
 
À
12/08/2015 10:07:27
Mike Yearwood
Toronto, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01623094
Message ID:
01623245
Vues:
60
>>>>>Hey all
>>>>>
>>>>>I've got a UDF that is something like a cross between SEEK and LOOKUP(). The problem is - calling a UDF is slower than native functions.
>>>>>
>>>>>The function is liberally scattered everywhere. The parameters do not match the LOOKUP function, which would have been virtually perfect. I know a search and replace might work, but that will break a lot of code too.
>>>>>
>>>>>So - an idea has been tickling around my mind,
>>>>>
>>>>>Given the existing call ... MYSEEK(seekthis,"inalias","thistag","returnthis")
>>>>>
>>>>>would it be possible to #DEFINE and make the above into something native at compile time?
>>>>>
>>>>>Thanks
>>>>Hi Mike,
>>>>
>>>>the cost of a call to a wrapper function is negligible, unless you are calling it thousands of times, which you shouldn't be doing anyway. So rewrite myseek to use LOOKUP() where appropriate, and you're done.
>>>>
>>>>Hank
>>>
>>>We are calling it many thousands of times because of it being used in queries. I disagree with the whole "premature optimization" schtick. Not optimizing at every chance is the true root of all evils.
>>
>>Hmmm, any reason why you're not using joins in your query?
>>Can you give an example in a query?
>
>Hi Walter
>
>There are definitely times where joins are not the best answer. I find I want to use joins where there will be filtering on the joined table. In many cases, where it's simply a decoding - a code to a description, that can be done with a lookup like utility.

I'd definitely try to get away from what you're doing in queries. Joins are usually the best (readable, maintainable, portable and fastest) answer for what you're trying to do. Alternatively, you might want to replace it with
IIF(SEEK(ValueField, cAlias, cTag), ReturnField, ReturnField) as Fieldname
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform