mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-29 05:41:50 +02:00
give opportunity for faster equating of ObjectSnapshot
This commit is contained in:
@@ -98,7 +98,7 @@ public struct ObjectSnapshot<O: DynamicObject>: ObjectRepresentation, Hashable {
|
|||||||
public static func == (_ lhs: Self, _ rhs: Self) -> Bool {
|
public static func == (_ lhs: Self, _ rhs: Self) -> Bool {
|
||||||
|
|
||||||
return lhs.id == rhs.id
|
return lhs.id == rhs.id
|
||||||
&& lhs.valuesRef == rhs.valuesRef
|
&& (lhs.generation == rhs.generation || lhs.valuesRef == rhs.valuesRef)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -122,12 +122,19 @@ public struct ObjectSnapshot<O: DynamicObject>: ObjectRepresentation, Hashable {
|
|||||||
self.id = objectID
|
self.id = objectID
|
||||||
self.context = context
|
self.context = context
|
||||||
self.values = values
|
self.values = values
|
||||||
|
self.generation = .init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// MARK: FilePrivate
|
// MARK: FilePrivate
|
||||||
|
|
||||||
fileprivate var values: [String: Any]
|
fileprivate var values: [String: Any] {
|
||||||
|
|
||||||
|
didSet {
|
||||||
|
|
||||||
|
self.generation = .init()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// MARK: Private
|
// MARK: Private
|
||||||
@@ -135,6 +142,8 @@ public struct ObjectSnapshot<O: DynamicObject>: ObjectRepresentation, Hashable {
|
|||||||
private let id: O.ObjectID
|
private let id: O.ObjectID
|
||||||
private let context: NSManagedObjectContext
|
private let context: NSManagedObjectContext
|
||||||
|
|
||||||
|
private var generation: UUID
|
||||||
|
|
||||||
private var valuesRef: NSDictionary {
|
private var valuesRef: NSDictionary {
|
||||||
|
|
||||||
return self.values as NSDictionary
|
return self.values as NSDictionary
|
||||||
|
|||||||
Reference in New Issue
Block a user