Speedup: calculate Item#hash once
This commit is contained in:
parent
91f476187b
commit
b371f4b404
@ -22,6 +22,7 @@ class Propane
|
|||||||
def initialize(rule, position)
|
def initialize(rule, position)
|
||||||
@rule = rule
|
@rule = rule
|
||||||
@position = position
|
@position = position
|
||||||
|
@_hash = [@rule, @position].hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# Hash function.
|
# Hash function.
|
||||||
@ -29,7 +30,7 @@ class Propane
|
|||||||
# @return [Integer]
|
# @return [Integer]
|
||||||
# Hash code.
|
# Hash code.
|
||||||
def hash
|
def hash
|
||||||
[@rule, @position].hash
|
@_hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# Compare Item objects.
|
# Compare Item objects.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user