Re: New Project Questions

new topic     » goto parent     » topic index » view thread      » older message » newer message

Thanks Alan and Ralf... I'll try these code snippets today and letcha
know.

Ralf Nieuwenhuijsen wrote:

> You would expect this one to be the fastest:
>
> function get_eof (integer fh)
> -- Reads all I/O until an EOF is found
>
> sequence ret
>
>     ret = gets (fh)
>     while ret[length(ret)] != -1 do
>         ret = ret & gets (fh)
>     end while
>
>     return ret[1..length(ret)-1]
> end function
>
> But this one could also be fast:
>
> constant DOZEN = 250 -- or something, just try..
>
> function get_eof (integer fh)
> -- Reads all I/O until an EOF is found
>
> sequence ret
> integer char
>
>     ret = gets (fh)
>     while ret[length(ret)] != -1 do
>         for 1 to DOZEN do
>             ret = append(ret, getc(fh))
>         end for
>     end while
>
>     for index = length(ret) to length(ret) - DOZEN by -1 do
>         if ret[index] != -1 then
>             return ret[1..index]
>         end if
>     end for
>
> end function

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu