Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Memory Pre-Allocation Trick?
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00721182
Message ID:
00722533
Views:
36
Hi David,

>I hope I didn't imply that VFP was totally as fast as C++

You didn't. We both know how fast C++ is. *s* My intention was to point out that even though VFP got a lot faster over time, it can't beat a C++ program regarding string handling.

>I really don't know why you'd ever do 15,360 dual memory allocations, ie once for the result of the replicate() and then concatenate it to the other string.

I've seen this a lot when generating XML/HTML. As you pointed out in another message, you can speed this up by assigning parts to intermediate strings. However, if you had 15,000 records, you would end up with as many memory allocations.

>Although I don't know, stuff() might map directly to memcpy() in some cases.

But the problem is again memory allocation. STUFF() doesn't stuff things into the first parameter, but returns a *new* string as a result. I did a quick test. There's no optimization in VFP if you assign the result to the same string that you passed as the first parameter.

In any case, I just wanted to give one more alternative to building string in VFP that doesn't rely on file operations and is still a viable way for VFP developers without going the C++ DLL route. *s*

Christof
--
Christof
Previous
Reply
Map
View

Click here to load this message in the networking platform