File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -340,15 +340,15 @@ extension OutputRawSpan {
340
340
) throws ( E) -> R
341
341
) throws ( E ) -> R {
342
342
guard let start = unsafe _pointer, capacity > 0 else {
343
- let buffer = unsafe UnsafeMutableRawBufferPointer( start : nil , count : 0 )
343
+ let buffer = UnsafeMutableRawBufferPointer ( _empty : ( ) )
344
344
var initializedCount = 0
345
345
defer {
346
346
_precondition( initializedCount == 0 , " OutputRawSpan capacity overflow " )
347
347
}
348
348
return unsafe try body ( buffer, & initializedCount)
349
349
}
350
350
let buffer = unsafe UnsafeMutableRawBufferPointer(
351
- start : start, count: capacity
351
+ _uncheckedStart : start, count: capacity
352
352
)
353
353
var initializedCount = _count
354
354
defer {
Original file line number Diff line number Diff line change @@ -100,6 +100,17 @@ public struct Unsafe${Mutable}RawBufferPointer {
100
100
@usableFromInline
101
101
internal let _position , _end : Unsafe ${ Mutable} RawPointer?
102
102
103
+ // This works around _debugPrecondition() impacting the performance of
104
+ // optimized code. (rdar://72246338)
105
+ @_alwaysEmitIntoClient
106
+ internal init (
107
+ @_nonEphemeral _uncheckedStart start: Unsafe ${ Mutable} RawPointer? ,
108
+ count: Int
109
+ ) {
110
+ unsafe _position = start
111
+ unsafe _end = start. map { unsafe $0 + _assumeNonNegative( count) }
112
+ }
113
+
103
114
/// Creates a buffer over the specified number of contiguous bytes starting
104
115
/// at the given pointer.
105
116
///
@@ -116,9 +127,14 @@ public struct Unsafe${Mutable}RawBufferPointer {
116
127
_debugPrecondition ( count >= 0 , " ${Self} with negative count " )
117
128
_debugPrecondition ( unsafe count == 0 || start != nil ,
118
129
" ${Self} has a nil start and nonzero count " )
130
+ unsafe self. init ( _uncheckedStart: start, count: count)
131
+ }
119
132
120
- unsafe _position = start
121
- unsafe _end = start. map { unsafe $0 + _assumeNonNegative( count) }
133
+ @safe
134
+ @_alwaysEmitIntoClient
135
+ public init ( _empty: ( ) ) {
136
+ unsafe _position = nil
137
+ unsafe _end = nil
122
138
}
123
139
}
124
140
You can’t perform that action at this time.
0 commit comments