Class: Veritas::Optimizer::Function::Connective::Binary::RedundantRightOperand

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

Overview

Optimize when the right operand is redundant

Constant Summary

Constants inherited from Veritas::Optimizer

Noop, VERSION

Instance Attribute Summary

Attributes included from Binary

#left, #right

Attributes inherited from Veritas::Optimizer

#operation

Instance Method Summary collapse

Methods included from Binary

#initialize

Methods inherited from Veritas::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)


229
230
231
232
# File 'lib/veritas/optimizer/function/connective/binary.rb', line 229

def optimizable?
  right = self.right
  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:



239
240
241
# File 'lib/veritas/optimizer/function/connective/binary.rb', line 239

def optimize
  right
end