From: Kurt Stephens Date: 2010-08-10T19:11:28+09:00 Subject: [ruby-core:31661] [Feature #3667] Speedup Date._parse and Date._strptime by using a Hash instead of a Date::Format::Bag Issue #3667 has been updated by Kurt Stephens. We've been running the hack below for a while... Jeremy's solution is more performant: # Date::Format::Bag#method_missing is a performance hog. if true && defined?(Date::Format) && defined?(Date::Format::Bag) class Date::Format::Bag def method_missing(sel, *args) # , &block) sel = sel.to_s t = sel.dup set = t.chomp!('=') t = t.intern # # There appear to be no callers like: # # e.foo(something) # # Thus do not interpret any arguments as # the *rest parameter since it creates Arrays # that are never referenced in: # # def foo(*rest); @elem[:foo]; end # expr = <<"END" class #{self.class} def #{t}(); @elem[#{t.inspect}]; end def #{t}=(arg); @elem[#{t.inspect}] = arg; end end END # $stderr.puts " **** #{self.class}\##{sel} =>\n#{expr}" eval(expr) if set @elem[t] = args[0] else @elem[t] end end end end ---------------------------------------- http://redmine.ruby-lang.org/issues/show/3667 ---------------------------------------- http://redmine.ruby-lang.org