[ListMonitor] [numberOfObjects()] Return count of fetchedObjects.

Casting `fetchedObjects` to `NSArray?` has better performance.
https://github.com/JohnEstropia/CoreStore/pull/288
This commit is contained in:
Ruslan Skorb
2018-12-06 10:56:30 +02:00
parent 6f655951aa
commit a9a73fa5c4

View File

@@ -232,10 +232,7 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
!self.isPendingRefetch || Thread.isMainThread,
"Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress."
)
return self.sections().reduce(0, { (numberOfObjects, sectionInfo) -> Int in
return numberOfObjects + sectionInfo.numberOfObjects
})
return (self.fetchedResultsController.fetchedObjects as NSArray?)?.count ?? 0
}
/**