Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Get rid of check for UnboundMethod in invoke (perf)

  • Loading branch information...
commit 15863661c33f2ba9bc03a6df325e97c285943152 1 parent d3936ad
@rtomayko rtomayko authored
Showing with 3 additions and 8 deletions.
  1. +3 −8 lib/sinatra/base.rb
View
11 lib/sinatra/base.rb
@@ -381,13 +381,7 @@ def indifferent_hash
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 @@ def route(verb, path, opts={}, &block)
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)
Please sign in to comment.
Something went wrong with that request. Please try again.