提交 4f043a48 编写于 作者: Y Yehuda Katz

More optimizations on respond_to after a profile and benching:

App with simple respond_to:
  def index
    respond_to do |format|
      format.html
      format.xml
      format.json
    end
  end

On JRuby (after complete hotspot warmup) -- 8% improvement:
  550 requests per second after this commit
  510 requests per second with old method_missing technique

On MRI (8% improvement):
  430 requests per second after this commit
  400 requests per second with old method_missing technique
上级 f4f8923c
......@@ -147,13 +147,9 @@ def any(*args, &block)
def self.generate_method_for_mime(mime)
sym = mime.is_a?(Symbol) ? mime : mime.to_sym
const = sym.to_s.upcase
class_eval <<-RUBY
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{sym}(&block) # def html(&block)
if Mime::SET.include?(Mime::#{const}) # if Mime::Set.include?(Mime::HTML)
custom(Mime::#{const}, &block) # custom(Mime::HTML, &block)
else # else
super # super
end # end
custom(Mime::#{const}, &block) # custom(Mime::HTML, &block)
end # end
RUBY
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册