mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
prepopulate the dispatch cache so we don't need the ThreadSafe cache.
This commit is contained in:
parent
e08696421f
commit
74a847771f
1 changed files with 9 additions and 7 deletions
|
@ -1,14 +1,10 @@
|
|||
# encoding: utf-8
|
||||
|
||||
require 'thread_safe'
|
||||
|
||||
module ActionDispatch
|
||||
module Journey # :nodoc:
|
||||
module Visitors # :nodoc:
|
||||
class Visitor # :nodoc:
|
||||
DISPATCH_CACHE = ThreadSafe::Cache.new { |h,k|
|
||||
h[k] = :"visit_#{k}"
|
||||
}
|
||||
DISPATCH_CACHE = {}
|
||||
|
||||
def accept(node)
|
||||
visit(node)
|
||||
|
@ -38,8 +34,14 @@ module ActionDispatch
|
|||
def visit_STAR(n); unary(n); end
|
||||
|
||||
def terminal(node); end
|
||||
%w{ LITERAL SYMBOL SLASH DOT }.each do |t|
|
||||
class_eval %{ def visit_#{t}(n); terminal(n); end }, __FILE__, __LINE__
|
||||
def visit_LITERAL(n); terminal(n); end
|
||||
def visit_SYMBOL(n); terminal(n); end
|
||||
def visit_SLASH(n); terminal(n); end
|
||||
def visit_DOT(n); terminal(n); end
|
||||
|
||||
private_instance_methods(false).each do |pim|
|
||||
next unless pim =~ /^visit_(.*)$/
|
||||
DISPATCH_CACHE[$1.to_sym] = pim
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue