Skip to content

Commit 50e7c98

Browse files
committed
[stdlib] MutableCollection fix to _SmallString
1 parent 473b573 commit 50e7c98

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

stdlib/public/core/SmallString.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,16 @@ extension _SmallString: RandomAccessCollection, MutableCollection {
191191

192192
@inlinable @inline(__always)
193193
internal subscript(_ bounds: Range<Index>) -> SubSequence {
194-
// TODO(String performance): In-vector-register operation
195-
return self.withUTF8 { utf8 in
196-
let rebased = UnsafeBufferPointer(rebasing: utf8[bounds])
197-
return _SmallString(rebased)._unsafelyUnwrappedUnchecked
194+
get {
195+
// TODO(String performance): In-vector-register operation
196+
return self.withUTF8 { utf8 in
197+
let rebased = UnsafeBufferPointer(rebasing: utf8[bounds])
198+
return _SmallString(rebased)._unsafelyUnwrappedUnchecked
199+
}
198200
}
201+
// This setter is required for _SmallString to be a valid MutableCollection.
202+
// Since _SmallString is internal and this setter unused, we cheat.
203+
@_alwaysEmitIntoClient set { fatalError() }
199204
}
200205
}
201206

0 commit comments

Comments
 (0)