From 5de5ecee06593beac3705d5ef6667ae51ec65b12 Mon Sep 17 00:00:00 2001 From: John Estropia Date: Sat, 26 Dec 2020 23:44:35 +0900 Subject: [PATCH] give opportunity for faster equating of ObjectSnapshot --- Sources/ObjectSnapshot.swift | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Sources/ObjectSnapshot.swift b/Sources/ObjectSnapshot.swift index df610f2..b4432ee 100644 --- a/Sources/ObjectSnapshot.swift +++ b/Sources/ObjectSnapshot.swift @@ -98,7 +98,7 @@ public struct ObjectSnapshot: ObjectRepresentation, Hashable { public static func == (_ lhs: Self, _ rhs: Self) -> Bool { return lhs.id == rhs.id - && lhs.valuesRef == rhs.valuesRef + && (lhs.generation == rhs.generation || lhs.valuesRef == rhs.valuesRef) } @@ -122,18 +122,27 @@ public struct ObjectSnapshot: ObjectRepresentation, Hashable { self.id = objectID self.context = context self.values = values + self.generation = .init() } // MARK: FilePrivate - fileprivate var values: [String: Any] + fileprivate var values: [String: Any] { + + didSet { + + self.generation = .init() + } + } // MARK: Private private let id: O.ObjectID private let context: NSManagedObjectContext + + private var generation: UUID private var valuesRef: NSDictionary {