Class: Axiom::Optimizer::Function::Connective::Binary::RedundantLeft

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

Overview

Optimize when the left 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 left operand is redundant

Returns:

  • (Boolean)


199
200
201
# File 'lib/axiom/optimizer/function/connective/binary.rb', line 199

def optimizable?
  operation.kind_of?(left.class) && right.eql?(left.right)
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 left operand is equivalent to the left

Returns:



208
209
210
# File 'lib/axiom/optimizer/function/connective/binary.rb', line 208

def optimize
  left
end