Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
The other way around
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00385262
Message ID:
00385288
Views:
13
>From Steve Black's "Text" session at DevConnections, John's would be more efficient. Some VFP optimization on StrVar = StrVar + ...

Bill,

I'm not so sure about that. See below
clear
lcfoo = 'ABCDEF'
lnstart = SECONDS()
FOR lnj = 1 TO 10000
  lcresult = ""
  FOR lni = 1 TO 6
    lcresult = SUBSTR(lcfoo, lni, 1) + lcresult
  NEXT
NEXT
lnstop = SECONDS()
? lnstop - lnstart  && Faster

lnstart = SECONDS()
FOR lnj = 10000 TO 1 STEP -1
  lcresult = ""
  FOR lni = 6 TO 1 STEP -1
    lcresult = SUBSTR(lcfoo, lni, 1) + lcresult
  NEXT
NEXT
lnstop = SECONDS()
? lnstop - lnstart && Slower
I ran this test enough times to be convinced that the first instance was always going to be faster (by about 2%). NBD. What was interesting was that the second nested iteration structure had to be changed. Originally, the lnj variable was incremented. I got an error message and had to change it to the above.
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform