Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Eof() or found()
Message
From
18/12/2004 02:31:34
 
 
To
18/12/2004 01:22:03
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Network:
Windows 2000 Pro
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00970039
Message ID:
00970288
Views:
14
><snip>
>>If you do not have to use CONTINUE, then:
>>SCAN it is faster, and for a single field LOOKUP() it is 100% faster
>>YOU CAN CHANGE
>>
>>LOCATE XXXX
>>IF FOUND()
>>   YYYY
>>ENDIF
>>
>>WITH
>>
>>SCAN XXXX
>>   YYYYY
>>   EXIT
>>ENDSCAN
>>* ATTENTION, ENDSCAN restore the SCAN workarea
>>
>>OR
>>
>>SCAN XXXX
>>  EXIT
>>ENSCAN
>>IF !EOF()
>> YYYY
>>ENDIF
>>
>>or for a single field
>>
>>IF LOOKUP() AND !EOF()
>>  YYYY
>>ENDIF
>>
>
>Hi Fabio. Any idea why there would be this difference in speed between these methods?
>
>Ciao!

Of course, only hypothesis:
- LOCATE it demands of the additional operations
because VFP have to store the expression and status
for execute a eventual successive CONTINUE operation;
- SCAN it does not have to make this job additional;
honestly this explanation me seems insufficient to explain all,
SCAN has an overload which had to the control of endscan.

- LOOKUP it is the true force of VFP, the inner code of search,
it is effectively 2x faster than LOCATE;
an explanation part is in the fact that LOCATE/SCAN must revalue
all the expression for every record, LOOKUP use a C data driver code (?)
( get the parm2 and compare with the field=parm3 )

An other small improvement can be obtained adding NOOPTIMIZE
(if it is sure that VFP cannot optimize the FOR),
in this case VFP jumps all the phase of analysis for the optimization.
If it is present WHILE, NOOPTIMIZE it is not required,
because with WHILE VFP it cannot optimize the FOR.

Ciao

Fabio
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform