Revert "[temporary] disable small-string support"

This reverts commit ea44ff9fc9.
This commit is contained in:
Guillaume Lessard
2025-04-03 10:05:55 -07:00
parent 9cc1947527
commit 2d50c6cce9
3 changed files with 14 additions and 18 deletions

View File

@@ -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)
}