From: Dave Thomas Date: 2000-12-16T08:10:02+09:00 Subject: [ruby-talk:7361] Re: Ruby performance question Eric Crampton writes: > I'm (generally) reading more data than could fit in physical memory, > so that's not really an option. OK, this is tacky, and probably not worth it, but it knocks about 15% of the run times on my box, using an 80,000 line input file with 6 key/value pairs per line. The idea is simply to avoid creating the intermediate object that contains a single key-value which is then split across the '='. Instead, we assume the input is well-formed and split into the final strings directly. h = Hash.new while line = gets a = line.chomp!.tr!('=', ',').split(',') 0.step(a.size-2, 2) do |i| h[a[i]] = a[i+1] end h.clear end Ugly, eh?