Skip to content

Commit 90e5ae6

Browse files
xwuphausler
authored andcommitted
[SE-0127] Remove calls to withUnsafe[Mutable]Pointers (#473)
1 parent cb72049 commit 90e5ae6

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

Foundation/NSCalendar.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,10 @@ public class NSCalendar: NSObject, NSCopying, NSSecureCoding {
417417
public func range(of unit: Unit, for date: Date) -> DateInterval? {
418418
var start: CFAbsoluteTime = 0.0
419419
var ti: CFTimeInterval = 0.0
420-
let res: Bool = withUnsafeMutablePointers(&start, &ti) { startp, tip in
421-
return CFCalendarGetTimeRangeOfUnit(_cfObject, unit._cfValue, date.timeIntervalSinceReferenceDate, startp, tip)
420+
let res: Bool = withUnsafeMutablePointer(&start) { startp in
421+
withUnsafeMutablePointer(&ti) { tip in
422+
return CFCalendarGetTimeRangeOfUnit(_cfObject, unit._cfValue, date.timeIntervalSinceReferenceDate, startp, tip)
423+
}
422424
}
423425

424426
if res {

Foundation/NSPropertyList.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ public class PropertyListSerialization : NSObject {
7070
public class func propertyList(from data: Data, options opt: ReadOptions = [], format: UnsafeMutablePointer<PropertyListFormat>?) throws -> Any {
7171
var fmt = kCFPropertyListBinaryFormat_v1_0
7272
var error: Unmanaged<CFError>? = nil
73-
let decoded = withUnsafeMutablePointers(&fmt, &error) { (outFmt: UnsafeMutablePointer<CFPropertyListFormat>, outErr: UnsafeMutablePointer<Unmanaged<CFError>?>) -> NSObject? in
74-
return unsafeBitCast(CFPropertyListCreateWithData(kCFAllocatorSystemDefault, data._cfObject, CFOptionFlags(CFIndex(opt.rawValue)), outFmt, outErr), to: NSObject.self)
73+
let decoded = withUnsafeMutablePointer(&fmt) { (outFmt: UnsafeMutablePointer<CFPropertyListFormat>) -> NSObject? in
74+
withUnsafeMutablePointer(&error) { (outErr: UnsafeMutablePointer<Unmanaged<CFError>?>) -> NSObject? in
75+
return unsafeBitCast(CFPropertyListCreateWithData(kCFAllocatorSystemDefault, data._cfObject, CFOptionFlags(CFIndex(opt.rawValue)), outFmt, outErr), to: NSObject.self)
76+
}
7577
}
7678
#if os(OSX) || os(iOS)
7779
format?.pointee = PropertyListFormat(rawValue: UInt(fmt.rawValue))!

Foundation/NSThread.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,11 @@ public class Thread: NSObject {
170170
public var stackSize: Int {
171171
get {
172172
var size: Int = 0
173-
return withUnsafeMutablePointers(&_attr, &size) { attr, sz in
174-
pthread_attr_getstacksize(attr, sz)
175-
return sz.pointee
173+
return withUnsafeMutablePointer(&_attr) { attr in
174+
withUnsafeMutablePointer(&size) { sz in
175+
pthread_attr_getstacksize(attr, sz)
176+
return sz.pointee
177+
}
176178
}
177179
}
178180
set {

0 commit comments

Comments
 (0)