mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[stdlib] Add an unsafe U[M]BP initializer to work around some inliner test failures
This commit is contained in:
@@ -208,7 +208,7 @@ extension _SmallString {
|
||||
// Restore the memory type of self._storage
|
||||
_ = rawPtr.bindMemory(to: RawBitPattern.self, capacity: 1)
|
||||
}
|
||||
return try f(UnsafeBufferPointer(start: ptr, count: count))
|
||||
return try f(UnsafeBufferPointer(_uncheckedStart: ptr, count: count))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -902,7 +902,7 @@ extension _StringObject {
|
||||
return sharedUTF8
|
||||
}
|
||||
return UnsafeBufferPointer(
|
||||
start: self.nativeUTF8Start, count: self.largeCount)
|
||||
_uncheckedStart: self.nativeUTF8Start, count: self.largeCount)
|
||||
}
|
||||
|
||||
// Whether the object stored can be bridged directly as a NSString
|
||||
|
||||
@@ -394,6 +394,15 @@ extension Unsafe${Mutable}BufferPointer: ${Mutable}Collection, RandomAccessColle
|
||||
}
|
||||
|
||||
extension Unsafe${Mutable}BufferPointer {
|
||||
@_alwaysEmitIntoClient
|
||||
internal init(
|
||||
@_nonEphemeral _uncheckedStart start: Unsafe${Mutable}Pointer<Element>?,
|
||||
count: Int
|
||||
) {
|
||||
_position = start
|
||||
self.count = count
|
||||
}
|
||||
|
||||
/// Creates a new buffer pointer over the specified number of contiguous
|
||||
/// instances beginning at the given pointer.
|
||||
///
|
||||
@@ -413,8 +422,7 @@ extension Unsafe${Mutable}BufferPointer {
|
||||
_debugPrecondition(
|
||||
count == 0 || start != nil,
|
||||
"Unsafe${Mutable}BufferPointer has a nil start and nonzero count")
|
||||
_position = start
|
||||
self.count = _assumeNonNegative(count)
|
||||
self.init(_uncheckedStart: start, count: _assumeNonNegative(count))
|
||||
}
|
||||
|
||||
@inlinable // unsafe-performance
|
||||
|
||||
Reference in New Issue
Block a user