Hello!

	After some digging around I discovered that using IO.sysread and
IO.syswrite is faster that IO.read and IO.syswrite, especially if you know
the size before. Although, mutiple calls to IO.seek, which uses fseek(3)
shifts internal buffering pointers, so IO.sysread is no longer usable. I
think that for complete system-level files we should have interface to
descriptor-based lseek(2) along with already existing seek. I'm not sure,
though that mixing different seeking methods is a good idea, but I propose
the following patch to io.c:

346a347,369
> rb_io_lseek_m(argc, argv, io)
>     int argc;
>     VALUE *argv;
>     VALUE io;
> {
>     VALUE offset, ptrname;
>     int whence;
>     OpenFile *fptr;
>     long pos;
>
>     rb_scan_args(argc, argv, "11", &offset, &ptrname);
>     if (argc == 1) whence = SEEK_SET;
>     else whence = NUM2INT(ptrname);
>
>     GetOpenFile(io, fptr);
>     pos = lseek(fileno(fptr->f), NUM2LONG(offset), whence);
>     if (pos == -1) rb_sys_fail(fptr->path);
>     clearerr(fptr->f);
>
>     return LONG2NUM(pos);
> }
>
> static VALUE
3598a3622
>     rb_define_method(rb_cIO, "lseek", rb_io_lseek_m, -1);

	This patch wasn't thoroughly tested, and may fail - so please wait for
approval or denial from Matz, and a word or two from Guy Decoux. Also, from
the compatibility side, lseek uses off_t type for both offset and return
value. I'm not very sure how it should map to built-in types and leave this
to cross-platform porting gurus.

Aristarkh A Zagorodnikov, Lead Programmer, W3D Group
http://www.w3d.ru /// xm / w3d.ru /// ICQ UIN 36987938