>A minor improvement might be the following:
>
>cnt = reallyBigString.length
>repeat with i = 1 to cnt
>    myCodeList.append(charToNum(reallyBigString.char[i])
>end repeat

A major improvement is to do all your work on char 1, then delete it as
you go:

on test
  parentString = member("test string").text
  put parentString.length
  
  reallyBigString = parentString
  myCodeList = []
  start = the milliseconds
  cnt = reallyBigString.length
  repeat with i = 1 to cnt
    append(myCodeList, charToNum(reallyBigString.char[i]))
  end repeat 
  put "Walk: " & string(the milliseconds - start)
  
  reallyBigString = parentString
  myCodeList = []
  start = the milliseconds
  cnt = reallyBigString.length
  repeat with i = 1 to cnt
    append(myCodeList, charToNum(reallyBigString.char[1]))
    delete char 1 of reallyBigString
  end repeat 
  put "Delete: " & string(the milliseconds - start)
  
end test

I just copied a groklaw page into a text member (about 63K) and ran the
above on a dual mirror 1.25GHz G4. (10.2.6) Here are the results:


-- 63679
-- "Walk: 14603"
-- "Delete: 9509"

Doesn't quite cut the execution time in half, but gets it in that
ballpark.

Tom McCrystal
[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email [EMAIL 
PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping 
with programming Lingo.  Thanks!]

Reply via email to