Speedup: calculate Item#hash once

This commit is contained in:
Josh Holtrop 2025-07-27 13:48:52 -04:00
parent 91f476187b
commit b371f4b404

View File

@ -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.