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