Skip to content

Commit

Permalink
Drop a useless helper
Browse files Browse the repository at this point in the history
...
  • Loading branch information
helje5 committed Nov 29, 2024
1 parent 23d94b4 commit 7709afb
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions Sources/ZeeQL/Control/ObjectTrackingContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,14 @@ open class ObjectTrackingContext : ObjectStore {
public func globalIDFor(object: AnyObject) -> GlobalID? {
if let smartObject = object as? ObjectWithGlobalID,
let gid = smartObject.globalID { return gid }
return gidToObject.firstKeyFor(value: object)
return gidToObject.first(where: { $0.value === object })?.key
}
@inlinable
public func globalIDFor<Object>(object: Object) -> GlobalID?
where Object: ObjectWithGlobalID
{
return object.globalID ?? gidToObject.firstKeyFor(value: object)
return object.globalID
?? gidToObject.first(where: { $0.value === object })?.key
}

@inlinable
Expand All @@ -165,15 +166,3 @@ open class ObjectTrackingContext : ObjectStore {
gidToObject.removeAll()
}
}


// MARK: - Helper

extension Dictionary where Value: AnyObject {

@usableFromInline
func firstKeyFor(value: Value) -> Key? {
first(where: { $0.value === value })?.key
}

}

0 comments on commit 7709afb

Please sign in to comment.