Skip to content

Commit 3059fb7

Browse files
committed
[Foundation] URL is actually already Hashable
I’m not sure why I was so convinced it wasn’t, but this certainly simplifies things.
1 parent bdd3a6b commit 3059fb7

File tree

1 file changed

+0
-33
lines changed

1 file changed

+0
-33
lines changed

stdlib/public/Darwin/Foundation/URL.swift

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -631,41 +631,8 @@ public struct URL : ReferenceConvertible, Equatable {
631631
public init(fileURLWithFileSystemRepresentation path: UnsafePointer<Int8>, isDirectory: Bool, relativeTo baseURL: __shared URL?) {
632632
_url = URL._converted(from: NSURL(fileURLWithFileSystemRepresentation: path, isDirectory: isDirectory, relativeTo: baseURL))
633633
}
634-
635-
public var hashValue: Int { // FIXME(hashValue): This should be removed once URL implements Hashable.
636-
return _url.hash
637-
}
638634

639-
@_alwaysEmitIntoClient // Introduced in 5.1
640635
public func hash(into hasher: inout Hasher) {
641-
// We expect this function to eventually satisfy the corresponding
642-
// requirement when URL starts conforming to Hashable. However, in the
643-
// meantime, it is useful to provide it so that user code can simply
644-
// declare the conformance if desired, without implementing anything.
645-
//
646-
// We want this definition to be available to all clients, even those
647-
// that get deployed with the 5.0 Foundation overlay where URL did not
648-
// provide this method. The `@_alwaysEmitIntoClient` attribute above
649-
// forces this function to get compiled into any user code that uses it.
650-
if #available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *) {
651-
// When we're on recent enough ABI, we forward the call to the
652-
// resilient implementation provided below. The availability check
653-
// above guarantees that the entry point will exist in the library
654-
// we link with.
655-
_hash(into: &hasher)
656-
} else {
657-
// This is the hash encoding that gets used with the 5.0 ABI. It has
658-
// to match the version of == implemented by 5.0, so it shouldn't
659-
// ever be changed.
660-
hasher.combine(_bridgeToObjectiveC())
661-
}
662-
}
663-
664-
@usableFromInline
665-
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
666-
internal func _hash(into hasher: inout Hasher) {
667-
// This code is beyond a resilience boundary. It has to be kept in
668-
// sync with the definition of == implemented below.
669636
hasher.combine(_url)
670637
}
671638

0 commit comments

Comments
 (0)