Skip to content

Commit 77a8e7b

Browse files
authored
Merge pull request #1590 from rauhul/pointer_initialization_update
2 parents e80d3b2 + ac9aae1 commit 77a8e7b

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

Foundation/FileManager.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -985,9 +985,7 @@ open class FileManager : NSObject {
985985
fatalError("string could not be converted")
986986
}
987987
let buf = UnsafeMutablePointer<Int8>.allocate(capacity: len)
988-
for i in 0..<len {
989-
buf.advanced(by: i).initialize(to: 0)
990-
}
988+
buf.initialize(repeating: 0, count: len)
991989
if !path._nsObject.getFileSystemRepresentation(buf, maxLength: len) {
992990
buf.deinitialize(count: len)
993991
buf.deallocate()

Foundation/NSURL.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,10 +566,8 @@ open class NSURL : NSObject, NSSecureCoding, NSCopying {
566566
let bufSize = Int(PATH_MAX + 1)
567567

568568
let _fsrBuffer = UnsafeMutablePointer<Int8>.allocate(capacity: bufSize)
569-
for i in 0..<bufSize {
570-
_fsrBuffer.advanced(by: i).initialize(to: 0)
571-
}
572-
569+
_fsrBuffer.initialize(repeating: 0, count: bufSize)
570+
573571
if getFileSystemRepresentation(_fsrBuffer, maxLength: bufSize) {
574572
return UnsafePointer(_fsrBuffer)
575573
}

0 commit comments

Comments
 (0)