line192 at gl_image.rb: next if line[0] == 35

Issue #17 new
ice huli created an issue

code at line 192 in file gl_image.rb does not work correctly.

next if line[0] == 35.

from ruby 1.9 it should be line[0].ord == 35 and the improvement seems very small comparing to line[0] == '#'.

Benchmark.bm do |x|
  x.report { 1000000.times do; "###xxxx"[0].ord == 35; end }
  x.report { 1000000.times do; "###xxxx"[0]=='#'; end }
x.report { 1000000.times do; "###xxxx"[0,1]=='#'; end }; end
       user     system      total        real
   0.234000   0.000000   0.234000 (  0.223001)
   0.266000   0.000000   0.266000 (  0.268994)
   0.281000   0.000000   0.281000 (  0.270004)

Comments (2)

  1. Log in to comment