From a9a73fa5c44ccc7f77eacd1ca4da7597e9cd9a89 Mon Sep 17 00:00:00 2001 From: Ruslan Skorb Date: Thu, 6 Dec 2018 10:56:30 +0200 Subject: [PATCH] [ListMonitor] [numberOfObjects()] Return `count` of `fetchedObjects`. Casting `fetchedObjects` to `NSArray?` has better performance. https://github.com/JohnEstropia/CoreStore/pull/288 --- Sources/ListMonitor.swift | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Sources/ListMonitor.swift b/Sources/ListMonitor.swift index 1db479d..39bc603 100644 --- a/Sources/ListMonitor.swift +++ b/Sources/ListMonitor.swift @@ -232,10 +232,7 @@ public final class ListMonitor: 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 } /**