LiangTyan Fui wrote:
> 
> Here is a function that I've written quite some time ago. It takes a list of
> text theList, separated by theitemDel, remove duplicate items in the list,
> and returns a new list without duplicate items.
> Unfortunately, this function running rather slowly on a large list (a few
> thousands records) - that is why I am posting here as a little "open
> source", Request For Comment: Make it faster guys!
> Remember, the sequence of the records cannot be changed, that say you are
> not likely to use sort.

On a test field of almost 8,000 lines, the original script takes 112
ticks on my Mac, compared to 8 ticks for this version:
 
function stripDup theList,theitemDel
  # verify param
  -- put the ticks into startticks -- Enable for time tests
  if theList= "" then return ""
  if theitemDel = "" then put cr into theitemDel
  put char 1 of theitemDel into theitemDel
  set the itemDelimiter to theitemDel
  put "" into theList2
  set wholematches to true
  repeat for each item i in theList
    if itemOffset(i, theList2) = 0
    then put i & theItemDel after theList2
  end repeat
  -- put the ticks - startticks -- Enable for time tests
  return theList2
end stripDup

-- 
Jacqueline Landman Gay         |     [EMAIL PROTECTED]
HyperActive Software           |     http://www.hyperactivesw.com

Archives: http://www.mail-archive.com/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to