From: martinus Date: 2004-12-29T07:31:48+09:00 Subject: Re: help on making ruby code faster Hi! I have played a bit with your code, the result is now about 55% faster. I have replaced your internal string representation (the @val) with an integer, wich makes the code both simpler and faster. The from_base36 method has also changed, it now looks like this: def self.from_base36(val) val = val.downcase raise ArgumentError unless val =~ /\A[a-z][a-z0-9]{24}\z/ n = 0 val.each_byte do |c| n = n*36 + @@rd36[c] end Guid.new(n) end Now the most time consuming task is each_byte, which takes about 60% of the CPU. Here is the full sourcecode: http://martinus.geekisp.com/files/guid.rb Martin