Loading ...
Sorry, an error occurred while loading the content.

Re: Slow execution

Expand Messages
  • Sheri
    ... Your pattern is doing a lot of backtracking. Following might make an improvement in speed. Instead of: ^!Find (?s)HREF= (http.+?) (.*?) RS1 Try: ^!Find
    Message 1 of 3 , Nov 4, 2009
    • 0 Attachment
      --- In ntb-clips@yahoogroups.com, Axel Berger <Axel-Berger@...> wrote:
      >
      > I have a file of about 13 000 lines of which about one in ten is link.
      > When running a clip on it, everything - dozens of document-wide replaces
      > - executes quite fast, except this bit:
      >
      > ^!Replace "~" >> "˜" WTAS
      > ^!Jump TEXT_START
      > :Loop
      > ^!Find "(?s)HREF="(http.+?)"(.*?)>" RS1
      > ^!IfError Weiter
      > ; start long line
      > ^!InsertSelect
      > ^$StrReplace("˜";"~";"^$GetSelection$";FALSE;FALSE)$
      > ; end long line
      > ^!InsertText ^$FileToUrl("^$GetSelection$")$
      > ^!Goto Loop
      > :Weiter
      > ^!Replace "˜" >> " " WTAS
      >
      > It starts off quick enough but slows down all through the file and
      > towards the end is something like a second per loop. Screen update off
      > does not do anything noticeable. The code snipped is part of a clip
      > called through ^!FarClip from an outer one.
      >
      > Is there a way to speed things up in this loop?
      > N.B: In TeX notation but not of course inside URLs a tilde denotes a
      > non-breaking space. That's what the two outer replaces deal with.
      >
      > Danke
      > Axel
      >

      Your pattern is doing a lot of backtracking. Following might make an improvement in speed.

      Instead of:
      ^!Find "(?s)HREF="(http.+?)"(.*?)>" RS1
      Try:
      ^!Find "(?<=HREF=\x22)http[^\x22>]++(?=\x22[^>]*+>)" RS

      Regards,
      Sheri
    Your message has been successfully submitted and would be delivered to recipients shortly.