Skip to content

Commit 2ab2431

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 f859dd1 commit 2ab2431

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
@@ -621,41 +621,8 @@ public struct URL : ReferenceConvertible, Equatable {
621621
public init(fileURLWithFileSystemRepresentation path: UnsafePointer<Int8>, isDirectory: Bool, relativeTo baseURL: __shared URL?) {
622622
_url = URL._converted(from: NSURL(fileURLWithFileSystemRepresentation: path, isDirectory: isDirectory, relativeTo: baseURL))
623623
}
624-
625-
public var hashValue: Int { // FIXME(hashValue): This should be removed once URL implements Hashable.
626-
return _url.hash
627-
}
628624

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

0 commit comments

Comments
 (0)