lib/bmg/operator/join.rb in bmg-0.16.0.pre.rc1 vs lib/bmg/operator/join.rb in bmg-0.16.0.pre.rc2
- old
+ new
@@ -40,9 +40,28 @@
def to_ast
[ :join, left.to_ast, right.to_ast, on ]
end
+ protected ### optimization
+
+ def _autowrap(type, options)
+ u_left, left_replaced = _unautowrap(left, options)
+ u_right, right_replaced = _unautowrap(right, options)
+ if (!left_replaced && !right_replaced)
+ super
+ else
+ u_left.join(u_right, on).autowrap(options)
+ end
+ end
+
+ def _unautowrap(operand, options)
+ return [operand, false] unless operand.is_a?(Operator::Autowrap)
+ return [operand, false] unless operand.same_options?(options)
+ [operand.send(:operand), true]
+ end
+ private :_unautowrap
+
protected ### inspect
def args
[ on ]
end