Skip to content

Commit 4d23610

Browse files
committed
[stdlib] document performance limitations on String’s span
1 parent f342396 commit 4d23610

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

stdlib/public/core/StringUTF8View.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,17 @@ extension String.UTF8View {
319319

320320
extension String.UTF8View {
321321

322+
/// A span over the UTF8 code units that make up this string.
323+
///
324+
/// - Note: In the case of bridged UTF16 String instances (on Apple
325+
/// platforms,) this property transcodes the code units the first time
326+
/// it is called. The transcoded buffer is cached, and subsequent calls
327+
/// to `span` can reuse the buffer.
328+
///
329+
/// Returns: a `Span` over the UTF8 code units of this String.
330+
///
331+
/// Complexity: O(1) for native UTF8 Strings,
332+
/// amortized O(1) for bridged UTF16 Strings.
322333
@available(SwiftStdlib 6.2, *)
323334
public var span: Span<UTF8.CodeUnit> {
324335
@lifetime(borrow self)

0 commit comments

Comments
 (0)