1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

Get rid of check for UnboundMethod in invoke (perf)

This commit is contained in:
Ryan Tomayko 2009-01-16 19:14:42 -08:00
parent d3936ad08b
commit 15863661c3

View file

@ -381,13 +381,7 @@ module Sinatra
end
def invoke(block)
res = catch(:halt) {
if block.is_a?(UnboundMethod)
block.bind(self).call
else
instance_eval(&block)
end
}
res = catch(:halt) { instance_eval(&block) }
case
when res.respond_to?(:to_str)
@response.body = [res]
@ -584,9 +578,10 @@ module Sinatra
define_method "#{verb} #{path}", &block
unbound_method = instance_method("#{verb} #{path}")
block = lambda { unbound_method.bind(self).call }
(routes[verb] ||= []).
push([pattern, keys, conditions, unbound_method]).last
push([pattern, keys, conditions, block]).last
end
def compile(path)