Skip to content

Commit ccdc218

Browse files
committed
[stdlib] _Hasher: append => combine
1 parent f1076fd commit ccdc218

26 files changed

+113
-113
lines changed

stdlib/public/core/Arrays.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2271,7 +2271,7 @@ extension ${Self}: Hashable where Element: Hashable {
22712271
@inlinable // FIXME(sil-serialize-all)
22722272
public func _hash(into hasher: inout _Hasher) {
22732273
for element in self {
2274-
hasher.append(element)
2274+
hasher.combine(element)
22752275
}
22762276
}
22772277
}

stdlib/public/core/Bool.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ extension Bool : Equatable, Hashable {
159159

160160
@inlinable // FIXME(sil-serialize-all)
161161
public func _hash(into hasher: inout _Hasher) {
162-
hasher.append((self ? 1 : 0) as UInt8)
162+
hasher.combine((self ? 1 : 0) as UInt8)
163163
}
164164

165165
@inlinable // FIXME(sil-serialize-all)

stdlib/public/core/CTypes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ extension OpaquePointer: Hashable {
186186

187187
@inlinable // FIXME(sil-serialize-all)
188188
public func _hash(into hasher: inout _Hasher) {
189-
hasher.append(Int(Builtin.ptrtoint_Word(_rawValue)))
189+
hasher.combine(Int(Builtin.ptrtoint_Word(_rawValue)))
190190
}
191191
}
192192

stdlib/public/core/ClosedRange.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ where Bound: Strideable, Bound.Stride: SignedInteger, Bound: Hashable {
177177
public func _hash(into hasher: inout _Hasher) {
178178
switch self {
179179
case .inRange(let value):
180-
hasher.append(0 as Int8)
181-
hasher.append(value)
180+
hasher.combine(0 as Int8)
181+
hasher.combine(value)
182182
case .pastEnd:
183-
hasher.append(1 as Int8)
183+
hasher.combine(1 as Int8)
184184
}
185185
}
186186
}
@@ -396,8 +396,8 @@ extension ClosedRange: Hashable where Bound: Hashable {
396396

397397
@inlinable // FIXME(sil-serialize-all)
398398
public func _hash(into hasher: inout _Hasher) {
399-
hasher.append(lowerBound)
400-
hasher.append(upperBound)
399+
hasher.combine(lowerBound)
400+
hasher.combine(upperBound)
401401
}
402402
}
403403

stdlib/public/core/Dictionary.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,11 +1453,11 @@ extension Dictionary: Hashable where Value: Hashable {
14531453
var commutativeHash = 0
14541454
for (k, v) in self {
14551455
var elementHasher = _Hasher()
1456-
elementHasher.append(k)
1457-
elementHasher.append(v)
1456+
elementHasher.combine(k)
1457+
elementHasher.combine(v)
14581458
commutativeHash ^= elementHasher.finalize()
14591459
}
1460-
hasher.append(commutativeHash)
1460+
hasher.combine(commutativeHash)
14611461
}
14621462
}
14631463

@@ -2436,8 +2436,8 @@ extension _NativeDictionaryBuffer where Key: Hashable
24362436
@inlinable // FIXME(sil-serialize-all)
24372437
@inline(__always) // For performance reasons.
24382438
internal func _bucket(_ k: Key) -> Int {
2439-
var hasher = _Hasher(seed: _storage.seed)
2440-
hasher.append(k)
2439+
var hasher = _Hasher(_seed: _storage.seed)
2440+
hasher.combine(k)
24412441
return hasher.finalize() & _bucketMask
24422442
}
24432443

stdlib/public/core/DropWhile.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ extension LazyDropWhileCollection.Index: Hashable where Base.Index: Hashable {
190190

191191
@inlinable // FIXME(sil-serialize-all)
192192
public func _hash(into hasher: inout _Hasher) {
193-
hasher.append(base)
193+
hasher.combine(base)
194194
}
195195
}
196196

stdlib/public/core/Flatten.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ extension FlattenCollection.Index : Hashable
236236

237237
@inlinable // FIXME(sil-serialize-all)
238238
public func _hash(into hasher: inout _Hasher) {
239-
hasher.append(_outer)
240-
hasher.append(_inner)
239+
hasher.combine(_outer)
240+
hasher.combine(_inner)
241241
}
242242
}
243243

stdlib/public/core/FloatingPointTypes.swift.gyb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,10 +1539,10 @@ extension ${Self} : Hashable {
15391539
v = 0
15401540
}
15411541
%if bits == 80:
1542-
hasher.append(v._representation.signAndExponent)
1543-
hasher.append(v.significandBitPattern)
1542+
hasher.combine(v._representation.signAndExponent)
1543+
hasher.combine(v.significandBitPattern)
15441544
%else:
1545-
hasher.append(v.bitPattern)
1545+
hasher.combine(v.bitPattern)
15461546
%end
15471547
}
15481548

stdlib/public/core/Hashable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,15 @@ public protocol Hashable : Equatable {
116116
extension Hashable {
117117
@inline(__always)
118118
public func _hash(into hasher: inout _Hasher) {
119-
hasher.append(self.hashValue)
119+
hasher.combine(self.hashValue)
120120
}
121121
}
122122

123123
// Called by synthesized `hashValue` implementations.
124124
@inline(__always)
125125
public func _hashValue<H: Hashable>(for value: H) -> Int {
126126
var hasher = _Hasher()
127-
hasher.append(value)
127+
hasher.combine(value)
128128
return hasher.finalize()
129129
}
130130

stdlib/public/core/Hashing.swift

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -165,26 +165,26 @@ internal struct _LegacyHasher {
165165
}
166166

167167
@inline(__always)
168-
internal mutating func append(_ value: Int) {
168+
internal mutating func combine(_ value: Int) {
169169
_hash = (_hash == 0 ? value : _combineHashValues(_hash, value))
170170
}
171171

172172
@inline(__always)
173-
internal mutating func append(_ value: UInt) {
174-
append(Int(bitPattern: value))
173+
internal mutating func combine(_ value: UInt) {
174+
combine(Int(bitPattern: value))
175175
}
176176

177177
@inline(__always)
178-
internal mutating func append(_ value: UInt32) {
179-
append(Int(truncatingIfNeeded: value))
178+
internal mutating func combine(_ value: UInt32) {
179+
combine(Int(truncatingIfNeeded: value))
180180
}
181181

182182
@inline(__always)
183-
internal mutating func append(_ value: UInt64) {
183+
internal mutating func combine(_ value: UInt64) {
184184
if UInt64.bitWidth > Int.bitWidth {
185-
append(Int(truncatingIfNeeded: value ^ (value &>> 32)))
185+
combine(Int(truncatingIfNeeded: value ^ (value &>> 32)))
186186
} else {
187-
append(Int(truncatingIfNeeded: value))
187+
combine(Int(truncatingIfNeeded: value))
188188
}
189189
}
190190

@@ -212,7 +212,7 @@ public struct _Hasher {
212212

213213
// NOT @inlinable
214214
@effects(releasenone)
215-
public init(seed: (UInt64, UInt64)) {
215+
public init(_seed seed: (UInt64, UInt64)) {
216216
self._core = Core(key: seed)
217217
}
218218

@@ -250,40 +250,40 @@ public struct _Hasher {
250250

251251
@inlinable
252252
@inline(__always)
253-
public mutating func append<H: Hashable>(_ value: H) {
253+
public mutating func combine<H: Hashable>(_ value: H) {
254254
value._hash(into: &self)
255255
}
256256

257257
// NOT @inlinable
258258
@effects(releasenone)
259-
public mutating func append(bits: UInt) {
260-
_core.append(bits)
259+
public mutating func combine(bits: UInt) {
260+
_core.combine(bits)
261261
}
262262
// NOT @inlinable
263263
@effects(releasenone)
264-
public mutating func append(bits: UInt32) {
265-
_core.append(bits)
264+
public mutating func combine(bits: UInt32) {
265+
_core.combine(bits)
266266
}
267267
// NOT @inlinable
268268
@effects(releasenone)
269-
public mutating func append(bits: UInt64) {
270-
_core.append(bits)
269+
public mutating func combine(bits: UInt64) {
270+
_core.combine(bits)
271271
}
272272

273273
// NOT @inlinable
274274
@effects(releasenone)
275-
public mutating func append(bits: Int) {
276-
_core.append(UInt(bitPattern: bits))
275+
public mutating func combine(bits: Int) {
276+
_core.combine(UInt(bitPattern: bits))
277277
}
278278
// NOT @inlinable
279279
@effects(releasenone)
280-
public mutating func append(bits: Int32) {
281-
_core.append(UInt32(bitPattern: bits))
280+
public mutating func combine(bits: Int32) {
281+
_core.combine(UInt32(bitPattern: bits))
282282
}
283283
// NOT @inlinable
284284
@effects(releasenone)
285-
public mutating func append(bits: Int64) {
286-
_core.append(UInt64(bitPattern: bits))
285+
public mutating func combine(bits: Int64) {
286+
_core.combine(UInt64(bitPattern: bits))
287287
}
288288

289289
// NOT @inlinable

0 commit comments

Comments
 (0)