On Sat, 16 Dec 2000, Joseph McDonald wrote:

> I found that a combination of your technique with Dave's technique
> to be the fastest:
> 
> def dt_readfile 
>   h = Hash.new 
>   file = File.new("keys") 
>   while line = file.gets 
>     record = line.chomp!.tr!('=', ',').split(',') 
>     h[record.shift] = record.shift until record.empty? 
>     # do stuff here... 
>     h.clear 
>   end 
> end 
> 
> results:
>                   user     system      total        real 
> david:        8.750000   0.148438   8.898438 (  9.019113) 
> joe:          8.773438   0.109375   8.882812 (  8.944328) 
> dt:           6.960938   0.046875   7.007812 (  7.130645) 
> orig:        11.304688   0.093750  11.398438 ( 11.776709) 


Right y'are.  I'd assumed that it was not doing the tr! that had
caused my version to pick up some time, but clearly that wasn't the
case.  (Now that I see it, of course, I wonder: what did I *think*
Dave's reason was for doing the tr! in the first place, if not speed?
Love of typing, perhaps?)


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav