Skip to content

Commit 5418b99

Browse files
committed
Address review feedback
1 parent 017c533 commit 5418b99

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

Foundation/NSCalendar.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,9 @@ open class NSCalendar : NSObject, NSCopying, NSSecureCoding {
583583
var at: CFAbsoluteTime = date.timeIntervalSinceReferenceDate
584584

585585
let res: Bool = withUnsafeMutablePointer(to: &at) { t in
586-
let copy = vector
586+
let count = Int32(vector.count)
587587
return vector.withUnsafeMutableBufferPointer { (vectorBuffer: inout UnsafeMutableBufferPointer<Int32>) in
588-
return _CFCalendarAddComponentsV(_cfObject, t, CFOptionFlags(opts.rawValue), compDesc, vectorBuffer.baseAddress!, Int32(copy.count))
588+
return _CFCalendarAddComponentsV(_cfObject, t, CFOptionFlags(opts.rawValue), compDesc, vectorBuffer.baseAddress!, count)
589589
}
590590
}
591591

@@ -604,9 +604,9 @@ open class NSCalendar : NSObject, NSCopying, NSSecureCoding {
604604
return intArrayBuffer.baseAddress!.advanced(by: idx)
605605
}
606606

607-
let copy = vector
607+
let count = Int32(vector.count)
608608
return vector.withUnsafeMutableBufferPointer { (vecBuffer: inout UnsafeMutableBufferPointer<UnsafeMutablePointer<Int32>>) in
609-
return _CFCalendarGetComponentDifferenceV(_cfObject, startingDate.timeIntervalSinceReferenceDate, resultDate.timeIntervalSinceReferenceDate, CFOptionFlags(opts.rawValue), compDesc, vecBuffer.baseAddress!, Int32(copy.count))
609+
return _CFCalendarGetComponentDifferenceV(_cfObject, startingDate.timeIntervalSinceReferenceDate, resultDate.timeIntervalSinceReferenceDate, CFOptionFlags(opts.rawValue), compDesc, vecBuffer.baseAddress!, count)
610610
}
611611
}
612612
if res {

TestFoundation/TestNSData.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -924,18 +924,17 @@ extension TestNSData {
924924
XCTAssertEqual(mutatingHello.count, helloLength * 2, "The length should have changed")
925925

926926
// Get the underlying data for hello2
927-
let copy = mutatingHello
928927
mutatingHello.withUnsafeMutableBytes { (bytes : UnsafeMutablePointer<UInt8>) in
929928
XCTAssertEqual(bytes.pointee, 0x68, "First byte should be 0x68")
930929

931930
// Mutate it
932931
bytes.pointee = 0x67
933932
XCTAssertEqual(bytes.pointee, 0x67, "First byte should be 0x67")
934-
XCTAssertEqual(copy[0], 0x67, "First byte accessed via other method should still be 0x67")
935-
936-
// Verify that the first data is still correct
937-
XCTAssertEqual(hello[0], 0x68, "The first byte should still be 0x68")
938933
}
934+
XCTAssertEqual(mutatingHello[0], 0x67, "First byte accessed via other method should still be 0x67")
935+
936+
// Verify that the first data is still correct
937+
XCTAssertEqual(hello[0], 0x68, "The first byte should still be 0x68")
939938
}
940939

941940

0 commit comments

Comments
 (0)