Class: Axiom::Optimizer::Function::Connective::Binary::RedundantRight

Inherits:
Axiom::Optimizer::Function::Connective::Binary show all
Defined in:
lib/axiom/optimizer/function/connective/binary.rb

Overview

Optimize when the right operand is redundant

Constant Summary

Constants inherited from Axiom::Optimizer

Identity, VERSION

Instance Attribute Summary

Attributes included from Binary

#left, #right

Attributes inherited from Axiom::Optimizer

#operation

Instance Method Summary collapse

Methods included from Binary

#initialize

Methods inherited from Axiom::Optimizer

chain, #initialize

Instance Method Details

#optimizable?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Test if the right operand is redundant

Returns:

  • (Boolean)


222
223
224
# File 'lib/axiom/optimizer/function/connective/binary.rb', line 222

def optimizable?
  operation.kind_of?(right.class) && left.eql?(right.left)
end

#optimizeFunction

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

A Binary connective with a redundant right operand is equivalent to the right

Returns:



231
232
233
# File 'lib/axiom/optimizer/function/connective/binary.rb', line 231

def optimize
  right
end