Functions and repeat for each
Dar Scott
dsc at swcp.com
Tue Jun 7 11:18:36 EDT 2005
On Jun 7, 2005, at 6:24 AM, ron barber wrote:
> put uniencode(return,"Japanese") into unireturn
> repeat for each line l in thetext
> put uniencode(l,"Japanese")&unireturn after newtext
> end repeat
> set the unicodetext of fld "Utext" to newtext
>
> is much much faster as the size of thetext gets large than:
>
> set the unicodetext of fld "Utext" to uniencode(thetext,"Japanese")
This is surprising. I have run some tests on 'put after' in the past
and it seems to behave as if some overhead such as reallocating memory
occurs every so often. That will tend to spread the reallocation cost.
It might be that uniEncode() will after a point get to reallocating
memory for every character.
This is wild speculation.
>
> This seems also to be true of the replacetext function as of 2.5 (I
> haven't tried the reportedly improved 2.6 yet)
> viz. This:
> repeat for each line l in thetext
> put replacetext (thetext,oldword,newword)&return after newtext
> end repeat
>
> is faster than:
> put replacetext (thetext,oldword,newword)&return into newtext
>
> when thetext is very large.
>
> Why is this true and is it generally known and I just missed it?
Yes. This is known. It might be that it is starting over after each
replace.
I tinkered with the new replaceText() and it seems to work.
--
**********************************************
DSC (Dar Scott Consulting & Dar's Lab)
http://www.swcp.com/dsc/
Programming and software
**********************************************
More information about the use-livecode
mailing list