Skip to content

Commit 45cb8b7

Browse files
committed
[SE-0206][stdlib] De-underscore Hasher
1 parent 8ef98b8 commit 45cb8b7

30 files changed

+71
-71
lines changed

lib/SILGen/SILGenExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3640,7 +3640,7 @@ getOrCreateKeyPathEqualsAndHash(SILGenModule &SGM,
36403640

36413641
SILValue hashCode;
36423642

3643-
// TODO: Combine hashes of the indexes using an inout _Hasher
3643+
// TODO: Combine hashes of the indexes using an inout Hasher
36443644
{
36453645
auto &index = indexes[0];
36463646

stdlib/private/StdlibUnittest/MinimalTypes.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public struct MinimalHashableValue : Equatable, Hashable {
116116
public static var equalImpl =
117117
ResettableValue<(Int, Int) -> Bool>({ $0 == $1 })
118118
public static var hashIntoImpl =
119-
ResettableValue<(Int, inout _Hasher) -> Void>({ $1.combine($0) })
119+
ResettableValue<(Int, inout Hasher) -> Void>({ $1.combine($0) })
120120

121121
public var value: Int
122122
public var identity: Int
@@ -140,12 +140,12 @@ public struct MinimalHashableValue : Equatable, Hashable {
140140
}
141141

142142
public var hashValue: Int {
143-
var hasher = _Hasher()
143+
var hasher = Hasher()
144144
hasher.combine(self)
145145
return hasher.finalize()
146146
}
147147

148-
public func _hash(into hasher: inout _Hasher) {
148+
public func _hash(into hasher: inout Hasher) {
149149
MinimalHashableValue.timesHashIntoWasCalled += 1
150150
MinimalHashableValue.hashIntoImpl.value(value, &hasher)
151151
}
@@ -169,7 +169,7 @@ public class MinimalHashableClass : Equatable, Hashable {
169169
public static var equalImpl =
170170
ResettableValue<(Int, Int) -> Bool>({ $0 == $1 })
171171
public static var hashIntoImpl =
172-
ResettableValue<(Int, inout _Hasher) -> Void>({ $1.combine($0) })
172+
ResettableValue<(Int, inout Hasher) -> Void>({ $1.combine($0) })
173173

174174
public var value: Int
175175
public var identity: Int
@@ -193,12 +193,12 @@ public class MinimalHashableClass : Equatable, Hashable {
193193
}
194194

195195
public var hashValue: Int {
196-
var hasher = _Hasher()
196+
var hasher = Hasher()
197197
hasher.combine(self)
198198
return hasher.finalize()
199199
}
200200

201-
public func _hash(into hasher: inout _Hasher) {
201+
public func _hash(into hasher: inout Hasher) {
202202
MinimalHashableClass.timesHashIntoWasCalled += 1
203203
MinimalHashableClass.hashIntoImpl.value(value, &hasher)
204204
}
@@ -220,7 +220,7 @@ public var GenericMinimalHashableValue_equalImpl =
220220
fatalError("GenericMinimalHashableValue_equalImpl is not set yet")
221221
})
222222
public var GenericMinimalHashableValue_hashIntoImpl =
223-
ResettableValue<(Any, inout _Hasher) -> Void>({ _ in
223+
ResettableValue<(Any, inout Hasher) -> Void>({ _ in
224224
fatalError("GenericMinimalHashableValue_hashIntoImpl is not set yet")
225225
})
226226

@@ -251,12 +251,12 @@ public struct GenericMinimalHashableValue<Wrapped> : Equatable, Hashable {
251251
}
252252

253253
public var hashValue: Int {
254-
var hasher = _Hasher()
254+
var hasher = Hasher()
255255
hasher.combine(self)
256256
return hasher.finalize()
257257
}
258258

259-
public func _hash(into hasher: inout _Hasher) {
259+
public func _hash(into hasher: inout Hasher) {
260260
GenericMinimalHashableValue_timesHashIntoWasCalled += 1
261261
GenericMinimalHashableValue_hashIntoImpl.value(value, &hasher)
262262
}
@@ -276,7 +276,7 @@ public var GenericMinimalHashableClass_equalImpl =
276276
fatalError("GenericMinimalHashableClass_equalImpl is not set yet")
277277
})
278278
public var GenericMinimalHashableClass_hashIntoImpl =
279-
ResettableValue<(Any, inout _Hasher) -> Void>({ _ in
279+
ResettableValue<(Any, inout Hasher) -> Void>({ _ in
280280
fatalError("GenericMinimalHashableClass_hashIntoImpl is not set yet")
281281
})
282282

@@ -307,12 +307,12 @@ public class GenericMinimalHashableClass<Wrapped> : Equatable, Hashable {
307307
}
308308

309309
public var hashValue: Int {
310-
var hasher = _Hasher()
310+
var hasher = Hasher()
311311
hasher.combine(self)
312312
return hasher.finalize()
313313
}
314314

315-
public func _hash(into hasher: inout _Hasher) {
315+
public func _hash(into hasher: inout Hasher) {
316316
GenericMinimalHashableClass_timesHashIntoWasCalled += 1
317317
GenericMinimalHashableClass_hashIntoImpl.value(value, &hasher)
318318
}

stdlib/private/StdlibUnittest/StdlibUnittest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2402,7 +2402,7 @@ public func checkEquatable<T : Equatable>(
24022402
}
24032403

24042404
internal func hash<H: Hashable>(_ value: H, seed: Int? = nil) -> Int {
2405-
var hasher = _Hasher()
2405+
var hasher = Hasher()
24062406
if let seed = seed {
24072407
hasher.combine(seed)
24082408
}

stdlib/public/core/AnyHashable.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ internal protocol _AnyHashableBox {
4848
/// no comparison is possible. Otherwise, contains the result of `==`.
4949
func _isEqual(to: _AnyHashableBox) -> Bool?
5050
var _hashValue: Int { get }
51-
func _hash(_into hasher: inout _Hasher)
51+
func _hash(_into hasher: inout Hasher)
5252

5353
var _base: Any { get }
5454
func _downCastConditional<T>(into result: UnsafeMutablePointer<T>) -> Bool
@@ -90,7 +90,7 @@ internal struct _ConcreteHashableBox<Base : Hashable> : _AnyHashableBox {
9090
}
9191

9292
@inlinable // FIXME(sil-serialize-all)
93-
func _hash(_into hasher: inout _Hasher) {
93+
func _hash(_into hasher: inout Hasher) {
9494
_baseHashable._hash(into: &hasher)
9595
}
9696

@@ -293,7 +293,7 @@ extension AnyHashable : Hashable {
293293
}
294294

295295
@inlinable // FIXME(sil-serialize-all)
296-
public func _hash(into hasher: inout _Hasher) {
296+
public func _hash(into hasher: inout Hasher) {
297297
_box._hash(_into: &hasher)
298298
}
299299
}

stdlib/public/core/Arrays.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2269,7 +2269,7 @@ extension ${Self}: Hashable where Element: Hashable {
22692269
}
22702270

22712271
@inlinable // FIXME(sil-serialize-all)
2272-
public func _hash(into hasher: inout _Hasher) {
2272+
public func _hash(into hasher: inout Hasher) {
22732273
hasher.combine(count) // discriminator
22742274
for element in self {
22752275
hasher.combine(element)

stdlib/public/core/Bool.swift

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

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

stdlib/public/core/CTypes.swift

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

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

stdlib/public/core/ClosedRange.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ where Bound: Strideable, Bound.Stride: SignedInteger, Bound: Hashable {
174174
}
175175

176176
@inlinable // FIXME(sil-serialize-all)
177-
public func _hash(into hasher: inout _Hasher) {
177+
public func _hash(into hasher: inout Hasher) {
178178
switch self {
179179
case .inRange(let value):
180180
hasher.combine(0 as Int8)
@@ -401,7 +401,7 @@ extension ClosedRange: Hashable where Bound: Hashable {
401401
}
402402

403403
@inlinable // FIXME(sil-serialize-all)
404-
public func _hash(into hasher: inout _Hasher) {
404+
public func _hash(into hasher: inout Hasher) {
405405
hasher.combine(lowerBound)
406406
hasher.combine(upperBound)
407407
}

stdlib/public/core/Dictionary.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,10 +1455,10 @@ extension Dictionary: Hashable where Value: Hashable {
14551455
}
14561456

14571457
@inlinable // FIXME(sil-serialize-all)
1458-
public func _hash(into hasher: inout _Hasher) {
1458+
public func _hash(into hasher: inout Hasher) {
14591459
var commutativeHash = 0
14601460
for (k, v) in self {
1461-
var elementHasher = _Hasher()
1461+
var elementHasher = Hasher()
14621462
elementHasher.combine(k)
14631463
elementHasher.combine(v)
14641464
commutativeHash ^= elementHasher.finalize()
@@ -2167,7 +2167,7 @@ internal struct _NativeDictionaryBuffer<Key, Value> {
21672167
//
21682168
// FIXME: Use an approximation of true per-instance seeding. We can't just
21692169
// use the base address, because COW copies need to share the same seed.
2170-
let seed = _Hasher._seed
2170+
let seed = Hasher._seed
21712171
let perturbation = bucketCount
21722172
_storage.seed = (seed.0 ^ UInt64(truncatingIfNeeded: perturbation), seed.1)
21732173
}
@@ -2442,7 +2442,7 @@ extension _NativeDictionaryBuffer where Key: Hashable
24422442
@inlinable // FIXME(sil-serialize-all)
24432443
@inline(__always) // For performance reasons.
24442444
internal func _bucket(_ k: Key) -> Int {
2445-
var hasher = _Hasher(_seed: _storage.seed)
2445+
var hasher = Hasher(_seed: _storage.seed)
24462446
hasher.combine(k)
24472447
return hasher.finalize() & _bucketMask
24482448
}

stdlib/public/core/DropWhile.swift

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

191191
@inlinable // FIXME(sil-serialize-all)
192-
public func _hash(into hasher: inout _Hasher) {
192+
public func _hash(into hasher: inout Hasher) {
193193
hasher.combine(base)
194194
}
195195
}

stdlib/public/core/Flatten.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ extension FlattenCollection.Index : Hashable
235235
}
236236

237237
@inlinable // FIXME(sil-serialize-all)
238-
public func _hash(into hasher: inout _Hasher) {
238+
public func _hash(into hasher: inout Hasher) {
239239
hasher.combine(_outer)
240240
hasher.combine(_inner)
241241
}

stdlib/public/core/FloatingPointTypes.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,7 @@ extension ${Self} : Hashable {
15311531
}
15321532

15331533
@inlinable // FIXME(sil-serialize-all)
1534-
public func _hash(into hasher: inout _Hasher) {
1534+
public func _hash(into hasher: inout Hasher) {
15351535
var v = self
15361536
if isZero {
15371537
// To satisfy the axiom that equality implies hash equality, we need to

stdlib/public/core/Hashable.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ public protocol Hashable : Equatable {
110110
var hashValue: Int { get }
111111

112112
/// Feed bits to be hashed into the hash function represented by `hasher`.
113-
func _hash(into hasher: inout _Hasher)
113+
func _hash(into hasher: inout Hasher)
114114
}
115115

116116
extension Hashable {
117117
@inlinable
118118
@inline(__always)
119-
public func _hash(into hasher: inout _Hasher) {
119+
public func _hash(into hasher: inout Hasher) {
120120
hasher.combine(self.hashValue)
121121
}
122122
}
@@ -125,7 +125,7 @@ extension Hashable {
125125
@inlinable
126126
@inline(__always)
127127
public func _hashValue<H: Hashable>(for value: H) -> Int {
128-
var hasher = _Hasher()
128+
var hasher = Hasher()
129129
hasher.combine(value)
130130
return hasher.finalize()
131131
}

stdlib/public/core/Hasher.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,14 @@ internal struct _BufferingHasher<Core: _HasherCore> {
247247
}
248248

249249
@_fixed_layout // FIXME: Should be resilient (rdar://problem/38549901)
250-
public struct _Hasher {
250+
public struct Hasher {
251251
internal typealias Core = _BufferingHasher<_SipHash13Core>
252252

253253
internal var _core: Core
254254

255255
@effects(releasenone)
256256
public init() {
257-
self._core = Core(seed: _Hasher._seed)
257+
self._core = Core(seed: Hasher._seed)
258258
}
259259

260260
@usableFromInline

stdlib/public/core/Integers.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3708,7 +3708,7 @@ extension ${Self} : Hashable {
37083708
}
37093709

37103710
@inlinable // FIXME(sil-serialize-all)
3711-
public func _hash(into hasher: inout _Hasher) {
3711+
public func _hash(into hasher: inout Hasher) {
37123712
// FIXME(hasher): To correctly bridge `Set`s/`Dictionary`s containing
37133713
// `AnyHashable`-boxed integers, all integer values are currently required
37143714
// to hash exactly the same way as the corresponding (U)Int64 value. To fix

stdlib/public/core/KeyPath.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class AnyKeyPath: Hashable, _AppendKeyPath {
5252
}
5353

5454
@inlinable // FIXME(sil-serialize-all)
55-
public func _hash(into hasher: inout _Hasher) {
55+
public func _hash(into hasher: inout Hasher) {
5656
return withBuffer {
5757
var buffer = $0
5858
while true {
@@ -446,7 +446,7 @@ internal struct ComputedPropertyID: Hashable {
446446
}
447447

448448
@inlinable // FIXME(sil-serialize-all)
449-
public func _hash(into hasher: inout _Hasher) {
449+
public func _hash(into hasher: inout Hasher) {
450450
hasher.combine(value)
451451
hasher.combine(isStoredProperty)
452452
hasher.combine(isTableOffset)
@@ -466,7 +466,7 @@ internal struct ComputedArgumentWitnesses {
466466
(_ xInstanceArguments: UnsafeRawPointer,
467467
_ yInstanceArguments: UnsafeRawPointer,
468468
_ size: Int) -> Bool
469-
// FIXME(hasher) Append to an inout _Hasher instead
469+
// FIXME(hasher) Combine to an inout Hasher instead
470470
internal typealias Hash = @convention(thin)
471471
(_ instanceArguments: UnsafeRawPointer,
472472
_ size: Int) -> Int
@@ -579,7 +579,7 @@ internal enum KeyPathComponent: Hashable {
579579
}
580580

581581
@inlinable // FIXME(sil-serialize-all)
582-
internal func _hash(into hasher: inout _Hasher) {
582+
internal func _hash(into hasher: inout Hasher) {
583583
var hasher = hasher
584584
func appendHashFromArgument(
585585
_ argument: KeyPathComponent.ArgumentRef?

stdlib/public/core/NewtypeWrapper.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extension _SwiftNewtypeWrapper where Self: Hashable, Self.RawValue : Hashable {
2222
}
2323

2424
@inlinable // FIXME(sil-serialize-all)
25-
public func _hash(into hasher: inout _Hasher) {
25+
public func _hash(into hasher: inout Hasher) {
2626
hasher.combine(rawValue)
2727
}
2828
}

stdlib/public/core/Optional.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ extension Optional: Hashable where Wrapped: Hashable {
422422
}
423423

424424
@inlinable // FIXME(sil-serialize-all)
425-
public func _hash(into hasher: inout _Hasher) {
425+
public func _hash(into hasher: inout Hasher) {
426426
switch self {
427427
case .none:
428428
hasher.combine(0 as UInt8)

stdlib/public/core/PrefixWhile.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ extension LazyPrefixWhileCollection.Index: Hashable where Base.Index: Hashable {
208208
}
209209

210210
@inlinable // FIXME(sil-serialize-all)
211-
public func _hash(into hasher: inout _Hasher) {
211+
public func _hash(into hasher: inout Hasher) {
212212
switch _value {
213213
case .index(let value):
214214
hasher.combine(value)

stdlib/public/core/Range.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ extension Range: Hashable where Bound: Hashable {
411411
}
412412

413413
@inlinable // FIXME(sil-serialize-all)
414-
public func _hash(into hasher: inout _Hasher) {
414+
public func _hash(into hasher: inout Hasher) {
415415
hasher.combine(lowerBound)
416416
hasher.combine(upperBound)
417417
}

stdlib/public/core/Reverse.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ extension ReversedCollection.Index: Hashable where Base.Index: Hashable {
197197
}
198198

199199
@inlinable // FIXME(sil-serialize-all)
200-
public func _hash(into hasher: inout _Hasher) {
200+
public func _hash(into hasher: inout Hasher) {
201201
hasher.combine(base)
202202
}
203203
}

0 commit comments

Comments
 (0)