Best array population & access optimization
Dar Scott
dsc at swcp.com
Fri Jun 20 12:20:01 EDT 2003
On Friday, June 20, 2003, at 02:19 PM, Mark Brownell wrote:
> put "-785314906, -1730169428, 805139163, -803545161, -1193168915,"
> into stringX
>
> set itemDelimiter to ","
>
> repeat with i = 1 to 5
> put item i of stringX into zap
> -- put value(zap) into myList[ i ]-- test one
> put zap into myList[ i ] -- test two & three
> end repeat
>
> -- put myList[1] -- test 1 & 2
>
> put myList[1] + 1 -- test three
>
> end mouseUp
>
> test one -- yields -785314906
> test two -- yields -785314906 ... I expected a string "-785314906"
> test three -- yields -785314905
In many cases you will not need to know whether Revolution uses string
numerals or an internal form of the number.
The above test two and three will put numeral strings into the arrays.
If you find that the encryption box is more efficient with internal
numbers in the array, then put (zap+0) into myList[i]. As you use the
numbers and replace them with calculated values, they will become and
stay the faster internal form. Unless you do some weird magic, the key
is always a numeral.
All results are strings once they get to the message box. The property
numberFormat is used to convert. Your numbers are hardly affected.
The quote marks will not show up on strings unless you put them in the
strings.
Because the Blowfish S-boxes have only 256 entries, you might see if
using numToChar(i) as the key gives you any speed advantage. Also,
since Blowfish uses 32-bit numbers, you might consider extracting four
char sets using a char chunk expression from a string instead of an
array and then use binaryEncode/binaryDecode.
Dar Scott
More information about the use-livecode
mailing list