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