Skip to content

Commit c0413c2

Browse files
committed
Removes redundant buffer zeroing in IndexPath
1 parent d30c63b commit c0413c2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Sources/Foundation/IndexPath.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,9 +641,9 @@ public struct IndexPath : ReferenceConvertible, Equatable, Hashable, MutableColl
641641
} else if count == 2 {
642642
_indexes = .pair(nsIndexPath.index(atPosition: 0), nsIndexPath.index(atPosition: 1))
643643
} else {
644-
var indexes = Array<Int>(repeating: 0, count: count)
645-
indexes.withUnsafeMutableBufferPointer { (buffer: inout UnsafeMutableBufferPointer<Int>) -> Void in
646-
nsIndexPath.getIndexes(buffer.baseAddress!, range: NSRange(location: 0, length: count))
644+
let indexes = Array<Int>(unsafeUninitializedCapacity: count) { buf, initializedCount in
645+
nsIndexPath.getIndexes(buf.baseAddress!, range: NSRange(location: 0, length: count))
646+
initializedCount = count
647647
}
648648
_indexes = .array(indexes)
649649
}

0 commit comments

Comments
 (0)