On Thu, Apr 17, 2003 at 10:34:53PM +0900, ts wrote:
> >>>>> "J" == Jim Freeze <jim / freeze.org> writes:
> 
> J> require 'mmapio'
> J> MMapIO.new(writefile, "w") { |f|
> 
>    Good luck, for this
> 
> J>   MMapIO.new(readfile).each { |line
> J>     # start rockin'
> J>     f << line
> J>   }
> J> }
> 
> 
> J> Has this been written before I start to do it myself?
> 
>  yes, but don't expect that it will be faster ...

I agree completely, because I've run essentially that program (but using
Ruby's standard I/O library) through a profiler. It spends around 5% of its
time doing I/O.

The problems are:
- you want to process the file a *line* at a time
- you are allocating a new String object for each line
- you are calling 'yield' on a Ruby block for each line

Regards,

Brian.