Skip to content

Commit 665839b

Browse files
committed
Use AnyHashable
1 parent 3ce1a3c commit 665839b

File tree

1 file changed

+3
-27
lines changed

1 file changed

+3
-27
lines changed

CodeEdit/Features/LSP/LSPCache.swift

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,17 @@
77

88
import Foundation
99

10-
struct AnyHashableData: Hashable {
11-
private let value: Any
12-
private let hashValueFunc: () -> Int
13-
private let equalsFunc: (Any) -> Bool
14-
15-
init<T: Hashable>(_ value: T) {
16-
self.value = value
17-
self.hashValueFunc = { value.hashValue }
18-
self.equalsFunc = { ($0 as? T) == value }
19-
}
20-
21-
static func == (lhs: AnyHashableData, rhs: AnyHashableData) -> Bool {
22-
return lhs.equalsFunc(rhs.value)
23-
}
24-
25-
func hash(into hasher: inout Hasher) {
26-
hasher.combine(hashValueFunc())
27-
}
28-
29-
var description: String {
30-
return String(describing: value)
31-
}
32-
}
33-
3410
struct NoExtraData: Hashable { }
3511

3612
struct CacheKey: Hashable {
3713
let uri: String
3814
let requestType: String
39-
let extraData: AnyHashableData?
15+
let extraData: AnyHashable?
4016

41-
init<ExtraData: Hashable>(uri: String, requestType: String, extraData: ExtraData? = nil) {
17+
init(uri: String, requestType: String, extraData: AnyHashable? = nil) {
4218
self.uri = uri
4319
self.requestType = requestType
44-
self.extraData = extraData.map(AnyHashableData.init)
20+
self.extraData = extraData
4521
}
4622

4723
static func == (lhs: CacheKey, rhs: CacheKey) -> Bool {

0 commit comments

Comments
 (0)