Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Fast string function
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01358927
Message ID:
01358936
Views:
37
>>It is definitely slower. I wish I remember the link to a discussion I mentioned. I asked on that site.
>
>Sure it's slower, but not slow, not in every type of usage.

In the meantime I think I found one of the discussions myself. http://forum.foxclub.ru/read.php?29,192734,page=1
***********************************************************************
m.s1=repl("A;;;",4000000)
m.s2=repl("A;",4000000)
m.sc=seconds()
m.s3=Reduce(m.s1,";")
?seconds()-m.sc
?m.s3==m.s2


function Reduce
lparameter m.st, m.ch
if len(m.ch)<1
return m.st
endif
if len(m.ch)>1
m.ch=left(m.ch,1)
endif

Declare Integer HeapCreate in Win32Api Integer, Integer, Integer
Declare Integer HeapDestroy in Win32Api Integer
Declare Integer HeapAlloc in Win32Api Integer, Integer, Integer

local m.hhnd, m.ptr, m.st1, m.st2

m.st2= ;
chr(85)+chr(139)+chr(236)+chr(87)+chr(86)+chr(80)+ ;
chr(83)+chr(81)+chr(82)+chr(139)+chr(117)+chr(8)+ ;
chr(139)+chr(69)+chr(12)+chr(139)+chr(125)+chr(16)+ ;
chr(139)+chr(93)+chr(20)+chr(139)+chr(11)+chr(51)+ ;
chr(219)+chr(58)+chr(6)+chr(116)+chr(14)+chr(50)+ ;
chr(228)+chr(255)+chr(54)+chr(143)+chr(7)+chr(70)+ ;
chr(71)+chr(67)+chr(73)+chr(117)+chr(240)+chr(235)+ ;
chr(13)+chr(128)+chr(252)+chr(1)+chr(116)+chr(4)+ ;
chr(254)+chr(196)+chr(235)+chr(235)+chr(70)+chr(73)+ ;
chr(117)+chr(225)+chr(139)+chr(77)+chr(20)+chr(137)+ ;
chr(25)+chr(90)+chr(89)+chr(91)+chr(88)+chr(94)+ ;
chr(95)+chr(139)+chr(229)+chr(93)+chr(194)+chr(16)+ ;
chr(0)

m.hhnd=HeapCreate(0,1024,1024)
m.ptr=HeapAlloc(m.hhnd,0,len(m.st2)+16)
Declare RtlMoveMemory in Win32API Integer, String st1, Integer cnt
RtlMoveMemory(m.ptr,m.st2,len(m.st2))

local m.st3,m.ln
m.st3=replicate(chr(0),len(m.st)+4)
m.ln=len(m.st)

Declare CallWindowProc in Win32API Integer, String, Integer, String @, Integer @

CallWindowProc(m.ptr, m.st+" ", asc(m.ch), @m.st3, @m.ln)
HeapDestroy(m.hhnd)

return left(m.st3,m.ln)
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform