OMG text processing performance 6.7 - 9.5

Ralph DiMola rdimola at evergreeninfo.net
Mon Feb 3 16:07:33 EST 2020


Also never forget the blazingly fast "filter" when appropriate.
 
Ralph DiMola
IT Director
Evergreen Information Services
rdimola at evergreeninfo.net


-----Original Message-----
From: use-livecode [mailto:use-livecode-bounces at lists.runrev.com] On Behalf
Of hh via use-livecode
Sent: Monday, February 03, 2020 3:19 PM
To: use-livecode at lists.runrev.com
Cc: hh
Subject: Re: OMG text processing performance 6.7 - 9.5

Parse1 is here always at least 30% faster than Parse2.

Yet another approach in LC 7/8/9 that I find to be very fast (especially for
a lot of hits in large strings, e.g. when searching for "and" or "the"):

-- Offset per ItemDelimiter
-- Searches for pStr in pSrc using pCase function Parse0 pStr, pSrc, pCase
  set the caseSensitive to pCase
  set the itemDelimiter to pStr
  put the length of pStr into tN0
  put 1 into tN
  repeat for each item tI in pSrc
    add the length of tI to tN
    put tN & cr after tOut
    add tN0 to tN
  end repeat
  return line 1 to -2 of tOut
end Parse0

> Richard G. wrote:
> 
> -- Offset in place:
> function Parse1 pStr, pSrc
>    put 0 into tStart
>    repeat
>      put offset(pStr, pSrc, tStart) into tOS
>      if tOS = 0 then exit repeat
>      add tOS to tStart
>      put tStart &cr after tOut
>    end repeat
>    return tOut
> end Parse1
> 
> -- Delete as you go:
> function Parse2 pStr, pSrc
>    put 0 into tStart
>    repeat
>      put offset( pStr, pSrc) into tOS
>      if tOS = 0 then exit repeat
>      delete char 1 to tOS of pSrc
>      add tOS to tStart
>      put tStart &cr after tOut
>    end repeat
>    return tOut
> end Parse2

_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list