Skip to content

Commit b4e0c6f

Browse files
Robert PietaRobert Pieta
authored andcommitted
Improvement performance using for over zip
1 parent 01fa634 commit b4e0c6f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Foundation/NSIndexSet.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,10 @@ open class NSIndexSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
116116
return false
117117
}
118118

119-
// Iterate over indexes to compare each
120-
for (range, element) in zip(_ranges, indexSet.rangeView) {
119+
// Iterate over indexes to compare each, prefer for over zip for better performance
120+
for i in 0..<_ranges.count {
121+
let range = _ranges[i]
122+
let element = indexSet.rangeView[i]
121123
let elementLength = element.upperBound - element.lowerBound
122124

123125
// Return false if the ranges do not match

0 commit comments

Comments
 (0)