Skip to content

Commit ce1a76c

Browse files
authored
Merge pull request #1077 from rudkx/work-around-slow-type-checking
2 parents f5068df + 179afd9 commit ce1a76c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Foundation/NSCFString.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,21 @@ internal class _NSCFString : NSMutableString {
5959

6060
internal final class _NSCFConstantString : _NSCFString {
6161
internal var _ptr : UnsafePointer<UInt8> {
62-
let offset = MemoryLayout<OpaquePointer>.size + MemoryLayout<Int32>.size + MemoryLayout<Int32>.size + MemoryLayout<_CFInfo>.size
62+
// FIXME: Split expression as a work-around for slow type
63+
// checking (tracked by SR-5322).
64+
let offTemp1 = MemoryLayout<OpaquePointer>.size + MemoryLayout<Int32>.size
65+
let offTemp2 = MemoryLayout<Int32>.size + MemoryLayout<_CFInfo>.size
66+
let offset = offTemp1 + offTemp2
6367
let ptr = Unmanaged.passUnretained(self).toOpaque()
6468
return ptr.load(fromByteOffset: offset, as: UnsafePointer<UInt8>.self)
6569
}
6670

6771
private var _lenOffset : Int {
68-
return MemoryLayout<OpaquePointer>.size + MemoryLayout<Int32>.size + MemoryLayout<Int32>.size + MemoryLayout<_CFInfo>.size + MemoryLayout<UnsafePointer<UInt8>>.size
72+
// FIXME: Split expression as a work-around for slow type
73+
// checking (tracked by SR-5322).
74+
let offTemp1 = MemoryLayout<OpaquePointer>.size + MemoryLayout<Int32>.size
75+
let offTemp2 = MemoryLayout<Int32>.size + MemoryLayout<_CFInfo>.size
76+
return offTemp1 + offTemp2 + MemoryLayout<UnsafePointer<UInt8>>.size
6977
}
7078

7179
private var _lenPtr : UnsafeMutableRawPointer {

0 commit comments

Comments
 (0)