mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Revert "[temporary] disable small-string support"
This reverts commit ea44ff9fc9.
This commit is contained in:
@@ -89,6 +89,7 @@ extension String {
|
||||
/// print(String(s1.utf8.prefix(15))!)
|
||||
/// // Prints "They call me 'B"
|
||||
@frozen
|
||||
@_addressableForDependencies
|
||||
public struct UTF8View: Sendable {
|
||||
@usableFromInline
|
||||
internal var _guts: _StringGuts
|
||||
@@ -345,15 +346,14 @@ extension String.UTF8View {
|
||||
#endif
|
||||
let count = _guts.count
|
||||
if _guts.isSmall {
|
||||
fatalError("Span over the small string form is not supported yet.")
|
||||
// let a = Builtin.addressOfBorrow(self)
|
||||
// let address = unsafe UnsafePointer<UTF8.CodeUnit>(a)
|
||||
// let span = unsafe Span(_unsafeStart: address, count: count)
|
||||
// return unsafe _overrideLifetime(span, borrowing: self)
|
||||
let a = Builtin.addressOfBorrow(self)
|
||||
let address = unsafe UnsafePointer<UTF8.CodeUnit>(a)
|
||||
let span = unsafe Span(_unsafeStart: address, count: count)
|
||||
return unsafe _overrideLifetime(span, borrowing: self)
|
||||
}
|
||||
_precondition(_guts.isFastUTF8)
|
||||
let buffer = unsafe _guts._object.fastUTF8
|
||||
_internalInvariant(count == buffer.count)
|
||||
_precondition(count == buffer.count)
|
||||
let span = unsafe Span(_unsafeElements: buffer)
|
||||
return unsafe _overrideLifetime(span, borrowing: self)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user