Skip to content

Commit 61629ea

Browse files
authored
Merge pull request #62352 from amartini51/string_count_91570469
Call out time complexity of `String.count`
2 parents a64fc3b + 7e58b81 commit 61629ea

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

stdlib/public/core/StringCharacterView.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ extension String: BidirectionalCollection {
3434
public var endIndex: Index { return _guts.endIndex }
3535

3636
/// The number of characters in a string.
37+
///
38+
/// To check whether a string is empty,
39+
/// use its `isEmpty` property instead of comparing `count` to zero.
40+
///
41+
/// - Complexity: O(n), where n is the length of the string.
3742
@inline(__always)
3843
public var count: Int {
3944
return distance(from: startIndex, to: endIndex)

0 commit comments

Comments
 (0)