Hi,
Problem: Looping over the words in a variable can be rather slow
since HC has to scan the string from the start each time, i.e. a loop
that looks at the first 3 words scans:
word 1
word 1, word 2
word 1, word 2, word 3
thus exponentially adding to the time it takes to get a word.
Solutions:
1) Since every time a script loops over all words of a text it uses
the "the number of words" function, which also scans the whole string
once, why not have that generate a look-up table, i.e. an array where
each item holds the start and end offset of the item with the number
of the array index.
2) Have each variable remember the start and end offsets of the last
word retrieved and its number. If a sequence of words is parsed, this
information would be examined beforehand, thus allowing to go on
parsing relative to the last word retrieved.
The second one would optimize sequential accessing of chunks the
most, but the first one would be better for dynamic loops, since it'd
even speed up if you only needed to get every second item. But it
could dramatically increase RAM requirements whenever the number of
items etc. is counted, while the second method would add to the
overall RAM requirements, since every variable would have to carry
around 3 additional fields with info on the last item retrieved.
Both of the above suggestions possibly wouldn't be able to improve
performance for nested chunks (e.g. "item 2 of line 1") very much,
though, so a construct like MC's "repeat for each" would definitely
be required in addition.
Anyway, does anybody have suggestions what could be done to optimize
chunks? Anthony?
BTW - I got this idea since Joker performs a 1200 word check at just
under 450 ticks, which sounds like too much for me. HC performs at
470, probably due to its overly cooperative nature.
Cheers,
-- M. Uli Kusterer
------------------------------------------------------------
http://www.weblayout.com/witness
'The Witnesses of TeachText are everywhere...'
--- HELP SAVE HYPERCARD: ---
Details at: http://www.hyperactivesw.com/SaveHC.html
Sign: http://www.giguere.uqam.ca/petition/hcpetition.html