Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
The other way around
Message
De
28/06/2000 00:15:14
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00385262
Message ID:
00385544
Vues:
13
Smart-ass :-)


>Bill, etal,
>
>Just for a frame of reference, this chunk of basic C++ code is 200 times faster than the VFP code. I ended up not using the _strrev() function because VFP strings can contain internal chr(0)'s which would cause incorrect results.
>
>
int CDequoteApp::Reverse( int nBufferLength, LPSTR cBuffer )
>{
>char *cpIn;
>char *cpOut;
>char  cSave;
>
>cpIn = cBuffer;
>cpOut = cpIn + nBufferLength - 1;
>
>while ( cpIn < cpOut )
>   {
>   cSave = *cpIn;
>   *cpIn++ = *cpOut;
>   *cpOut-- = cSave;
>   }
>
>return ( nBufferLength );
>}
>
>N = 400
>
>dimension laX[N]
>
>for i = 1 to N
>   laX[i] = replicate( "abc123", i )
>endfor
>
>? "start"
>lnStart = seconds()
>
>for i = 1 to N
>   lcX = StrRev( laX[i] )
>endfor
>
>?? seconds() - lnStart
>
>declare integer Reverse in C:\VFP6App\df_foxpro\dequote\Release\dequote.dll integer nBufferLength, string @ cBuffer
>
>lnStart = seconds()
>
>for i = 1 to N
>   lcX = laX[i]
>   = Reverse( len( lcX ), @lcX )
>endfor
>
>?? seconds() - lnStart
>
>return
>
>FUNCTION StrRev( cText )
>
>LOCAL lcresult, lni, lnlast
>lnlast = LEN(cText)
>lcresult = ""
>FOR lni = 1 TO lnlast
> lcresult = SUBSTR(cText, lni, 1) + lcresult
>NEXT
>RETURN lcresult
>ENDFUNC
>
>>>I'd do the whole thing with a C++ library call that would beat the snot out of VFP in this case.
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform