which is faster (a repeat structure question)

Ken Ray kray at sonsothunder.com
Thu Sep 26 02:45:01 EDT 2002


Shao,

In the example you give, I would bet the "repeat with" is faster, since it
only has to do 128 "replace" statements, whereas the "repeat for each" would
have to adjust each character one at a time. It probably depends on the size
of what's being converted - if it's small, "repeat for each", if it's large,
"repeat with" (in *this* example).

Just my thoughts without benchmarking it...

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/

----- Original Message -----
From: "Shao Sean" <shaosean at unitz.ca>
To: "Mail-List MetaCard" <metacard at lists.runrev.com>
Cc: "Mail-List MetaCard" <metacard at lists.runrev.com>
Sent: Thursday, September 26, 2002 1:13 AM
Subject: which is faster (a repeat structure question)


> repeat with i = 127 to 255
>    replace numToChar(i) with ("=" & toUpper(baseConvert(i,10,16))) in
> inputData
> end repeat
> return inputData
>
>
> repeat for each char inputDataChar in inputData
>   if (charToNum(inputDataChar) >= 127) then
>     put "=" & toUpper(baseConvert(charToNum(inputDataChar),10,16)) after
> outputData
>   else
>     put inputDataChar after outputData
>   end if
> end repeat
> return outputData
>
>
> is "repeat for each" really that much quicker?  i realize that the amount
of
> data being converted is a major factor, but the first one only needs to
loop
> 128 times whereas the second one has to loop for each char, which could be
> well more than 128 chars..
>
> TIA - Sean
>
> _______________________________________________
> metacard mailing list
> metacard at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/metacard
>




More information about the metacard mailing list