From ff8fbae5682b992dae28d6e46bd8267b447880ca Mon Sep 17 00:00:00 2001 From: Ruslan Skorb Date: Sat, 24 Nov 2018 16:23:36 +0200 Subject: [PATCH] [ListMonitor] [subscript(safeSectionIndex:safeItemIndex:)] Use `subscript(indexPath:)` after the validation of `sectionIndex` and `itemIndex` to get an object. There is a performance problem in Swift when getting an object from the Objective-C array with a large number of objects using subscript. It requires casting the array between Objective-C and Swift, that is pretty slow. --- Sources/ListMonitor.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/ListMonitor.swift b/Sources/ListMonitor.swift index 86ce96e..1750802 100644 --- a/Sources/ListMonitor.swift +++ b/Sources/ListMonitor.swift @@ -144,7 +144,7 @@ public final class ListMonitor: Hashable { return nil } - return ObjectType.cs_fromRaw(object: section.objects![itemIndex] as! NSManagedObject) + return self[IndexPath(indexes: [sectionIndex, itemIndex])] } /**