Way to speed up append strings?

David Kwinter david at kwinter.ca
Sun Nov 14 14:11:20 EST 2004


You could put new data into elements of an array, keep track of the keys 
using a variable, then "combine" them into one string at the end, prior to 
writing to a file.

do this once
put 0 into i

then for each new string
add 1 to i
put "some new data" into newPrefData[i]

then at the end
combine newPrefData using tab

----- Original Message ----- 
From: "Frank Leahy" <frank at backtalk.com>
To: <use-revolution at lists.runrev.com>
Sent: Sunday, November 14, 2004 7:20 AM
Subject: Way to speed up append strings?


>I have a preferences file that is fairly large (30K+), and it's created 
>on-the-fly using "append string" functions, e.g.
>    put "this data and that data..." after thePrefs
>    put "some more data..." after thePrefs
>    put "even more data..." after thePrefs
>
> This is getting slower than I'd like, and it appears that the slowdown is 
> because the append functions are getting slow.  I'm guessing that RunRev 
> is reallocating memory on each append, then copying the existing string 
> and the appended string into the newly allocated memory.  And because I 
> have lots of little appends this really slows things down (and no, there's 
> no way to make the appends longer and therefore fewer...).
>
> My question is this: is there a way to tell RunRev that I want it should 
> start with a big string block (e.g. 64K of memory), when I first create 
> the string?
>
> If not, I'll have to go to a "write to temp file and then re-read from 
> temp file" type of solution (because writing and reading to a temp file 
> appears to be significantly faster than doing lots of little appends).
>
> Thanks,
> -- Frank
>
> Web Photos Pro: Software for Photo Bloggers and Other Photo Power Users
> See us on the web at http://www.webphotospro.com/
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 



More information about the use-livecode mailing list