On Sat, 10 Sep 2005, Glenn M. Lewis wrote:

> and now the parsing time goes down to 26 seconds!!!   YAHOO!!!

Good.
>
>  def Contract.parseFile(file)
>    return if @@files.has_key?(file)
>    return unless File.exists?(file)
>    @@files[file] = 1
>    print "Parsing file #{file}..."
pre-create fields, contract, etc so they don't get called
into being each loop

      fields, contract, mydate, tick = nil, nil, nil, nil
      year, month, day = nil, nil, nil

>    File.open(file, "rb") do |io|
>      io.each_line do |line|

Coould do that in one I think
      File.open(file, 'rb').each_line do |line|
because you don't use io again.

> 	fields = line.chomp.split(/,/)
> 	next if fields.size < 8
> 	contract = Contract.open(fields[0])

I'm a bit concerned that I don't see a matching close for this, or a
block passed in instead.

> 	next unless contract
> 	datestring = fields[1]
> 	# year  = datestring[0..1].to_i
> 	# month = datestring[2..3].to_i
> 	# day   = datestring[4..5].to_i
> 	year, month, day = datestring[0..5].scan(/../).collect {|s| s.to_i }
> 	# puts "year=#{year}, month=#{month}, day=#{day}"
> 	# RUBY BUG?!?  Can't use 'date' here... as that messes up findTick's 
> 'date'...
> 	mydate  = Time.local((year < 50 ? year+2000 : year+1900), month, day)
> 	tick = Tick.new(mydate, fields[2].to_f, fields[3].to_f,
> 			fields[4].to_f, fields[5].to_f,
> 			fields[6].to_i, fields[7].to_i)
> 	contract.addTick(tick)
>      end
>    end
>    puts "done"
>  end
>
         Hugh