lineoffset slower than "repeat for each line j" ?

jbv jbv.silences at club-internet.fr
Thu May 29 05:29:24 EDT 2008


Hi list,

Please excuse the remark, but I'd like to share something I just noticed

and that surprised me a bit...

I have a file loaded into a variable, which is about 8 Mb and consists
in
about 40000 lines of 3 items each (itemdel is tab).

I need to know which line contains a certain value as 3rd item.

Fist I used the following :
    get lineoffset(tab & "39900",myVar)

which happens to take 200 ms when the found line is near the end.


Then I tried this :
    put 0 into x
    repeat for each line j in myVar
        add 1 to x
        if last item of j = "39900" then
            put x into tResult
            exit repeat
        end if
    end repeat

Surprisingly, this takes only 106 ms !!!
If anyone asked me beforehand, I would have sweared that a built-in Rev
function would run faster than a bunch of transcript lines of code...

I'm using Rev cgi 2.5 on a Linux server.

JB




More information about the use-livecode mailing list