Deduplicate calls to Mutator.identity
This commit is contained in:
parent
f5a4093f0b
commit
b132b46d10
2 changed files with 18 additions and 6 deletions
|
@ -1,3 +1,3 @@
|
||||||
---
|
---
|
||||||
threshold: 18
|
threshold: 18
|
||||||
total_score: 789
|
total_score: 791
|
||||||
|
|
|
@ -13,9 +13,9 @@ module Mutant
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def self.each(node, parent = nil, &block)
|
def self.each(input, parent = nil, &block)
|
||||||
return to_enum(__method__, node, parent) unless block_given?
|
return to_enum(__method__, input, parent) unless block_given?
|
||||||
Registry.lookup(node).new(node, parent, block)
|
Registry.lookup(input).new(input, parent, block)
|
||||||
|
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
@ -92,7 +92,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def new?(object)
|
def new?(object)
|
||||||
!@seen.include?(self.class.identity(object))
|
!@seen.include?(identity(object))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add object to guarded values
|
# Add object to guarded values
|
||||||
|
@ -104,7 +104,19 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def guard(object)
|
def guard(object)
|
||||||
@seen << self.class.identity(object)
|
@seen << identity(object)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Return identity for input
|
||||||
|
#
|
||||||
|
# @param [Object] input
|
||||||
|
#
|
||||||
|
# @return [Object]
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
def identity(input)
|
||||||
|
self.class.identity(input)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dispatch node generations
|
# Dispatch node generations
|
||||||
|
|
Loading…
Reference in a new issue