Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Faststring.dll
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Produits tierce partie
Titre:
Divers
Thread ID:
01674989
Message ID:
01675110
Vues:
160
Hey I'm so glad I posted this... two great solutions now that improve over what I came up with :-)

Haven't tried this yet but this looks like another clean read/only solution.


+++ Rick ---


>Hi Rick,
>
>I've posted this as a comment on your blog... If you parse a long string in VFP and don't modify the string as you go, it's a lot faster to copy the string in memory and then use SYS(2600) to access any part of it. This avoids any performance issues due to locking and unlocking the string or providing a safe copy for API functions.
>
>LOCAL lnX, lcString, lnLength, lnBase, lnSecs
>lcString = REPLICATE("1234567890",100000)
>
>	Declare Integer HeapAlloc in Win32Api Integer, Integer, Integer
>	Declare Integer HeapFree in Win32APi Integer, Integer, Integer
>	Declare Long GetProcessHeap in Win32API
>      
>lnLength = LEN(lcString)
>TRANSFORM(lnLength,"9,999,999")
>
>lnSecs = SECONDS()
>
>lnBase = HeapAlloc( GetProcessHeap(), 0, m.lnLength )
>Sys(2600, m.lnBase, m.lnLength, m.lcString)
>FOR lnX = 1 TO lnLength
>	lcVal = Sys(2600,m.lnBase-1+m.lnX,1)
>ENDFOR
>HeapFree( GetProcessHeap(), 0, m.lnBase )
>
>? "SYS(2600): " +  TRANSFORM(SECONDS() - lnSecs )
>
>On my machine, this runs in 0.33 seconds vs 37 seconds for the SUBSTR() approach.
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform