Module: AST::Processor::Mixin
- Defined in:
- opal/lib/opal/parser/patch.rb
Instance Method Summary collapse
-
#process(node) ⇒ Object
This patch to #process removes a bit of dynamic abilities (removed call to node.to_ast) and it tries to optimize away the string operations and method existence check by caching them inside a processor.
Instance Method Details
#process(node) ⇒ Object
This patch to #process removes a bit of dynamic abilities (removed call to node.to_ast) and it tries to optimize away the string operations and method existence check by caching them inside a processor.
This is the second most inefficient call in the compilation phase so an optimization may be warranted.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'opal/lib/opal/parser/patch.rb', line 63 def process(node) return if node.nil? @_on_handler_cache ||= {} type = node.type on_handler = @_on_handler_cache[type] ||= begin handler = :"on_#{type}" handler = :handler_missing unless respond_to?(handler) handler end send(on_handler, node) || node end |