mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
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
This commit is contained in:
@@ -147,13 +147,9 @@ module ActionController #:nodoc:
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user