[フレーム]

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.

145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'opal/lib/opal/parser/patch.rb', line 145
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

AltStyle によって変換されたページ (->オリジナル) /