Skip to content

Commit fd0c387

Browse files
xwulorentey
authored andcommitted
[stdlib] Mix lowerBound a little in Range.hashValue and ClosedRange.hashValue
1 parent 6530c88 commit fd0c387

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

stdlib/public/core/ClosedRange.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,10 @@ extension ClosedRange: Equatable {
385385
extension ClosedRange : Hashable where Bound : Hashable {
386386
@_inlineable // FIXME(sil-serialize-all)
387387
public var hashValue: Int {
388-
return _combineHashValues(lowerBound.hashValue, upperBound.hashValue)
388+
var result = 0
389+
result = _combineHashValues(result, lowerBound.hashValue)
390+
result = _combineHashValues(result, upperBound.hashValue)
391+
return result
389392
}
390393
}
391394

stdlib/public/core/Range.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,10 @@ extension Range: Equatable {
401401
extension Range : Hashable where Bound : Hashable {
402402
@_inlineable // FIXME(sil-serialize-all)
403403
public var hashValue: Int {
404-
return _combineHashValues(lowerBound.hashValue, upperBound.hashValue)
404+
var result = 0
405+
result = _combineHashValues(result, lowerBound.hashValue)
406+
result = _combineHashValues(result, upperBound.hashValue)
407+
return result
405408
}
406409
}
407410

0 commit comments

Comments
 (0)