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:
parent
d3936ad08b
commit
15863661c3
1 changed files with 3 additions and 8 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue