Kevan Hashemi a écrit :
Dear GPC Users,
I use long strings to pass numerical data into and out of a shared library I compile from Pascal. Right now, I generate a long string of numbers like this.
program string_demo;
var long_string:string(100000); i:integer;
begin long_string:=''; for i:=1 to 10000 do writestr(long_string,long_string,i:1,' '); end.
Clearly, this is inefficient. It takes 200 ms on my machine. If I use an array of characters instead of a string, and append each new entry to the array, execution time drops to 10 ms.
I can't see a way of using GPC's writestr, concat, or trim functions to accelerate my string generation. I can't alter the long_string.length field directly.
SetLength(long_string, 999999).
If I could fill up the string with spaces first, I could
use the string as an array, then trim the spaces off the end. But filling up the string with spaces requires multiple calls to writestr, so I'm back where I started.
It seems to me that I'm missing an obvious solution to my problem, and I thought you might point it out to me.
Maurice