From 7709afbf936cfd7f820cb54af329a8de9c456f39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helge=20He=C3=9F?= Date: Fri, 29 Nov 2024 23:20:25 +0100 Subject: [PATCH] Drop a useless helper ... --- .../ZeeQL/Control/ObjectTrackingContext.swift | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/Sources/ZeeQL/Control/ObjectTrackingContext.swift b/Sources/ZeeQL/Control/ObjectTrackingContext.swift index 5366ce3..dda5f17 100644 --- a/Sources/ZeeQL/Control/ObjectTrackingContext.swift +++ b/Sources/ZeeQL/Control/ObjectTrackingContext.swift @@ -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) -> GlobalID? where Object: ObjectWithGlobalID { - return object.globalID ?? gidToObject.firstKeyFor(value: object) + return object.globalID + ?? gidToObject.first(where: { $0.value === object })?.key } @inlinable @@ -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 - } - -}