Skip to content

Commit b540204

Browse files
committed
stdlib: specify the count of Span and MutableSpan as _assumeNonNegative
1 parent cf16c1b commit b540204

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

stdlib/public/core/Span/MutableSpan.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ extension MutableSpan where Element: ~Copyable {
237237
extension MutableSpan where Element: ~Copyable {
238238

239239
@_alwaysEmitIntoClient
240-
public var count: Int { _count }
240+
public var count: Int { _assumeNonNegative(_count) }
241241

242242
@_alwaysEmitIntoClient
243243
public var isEmpty: Bool { _count == 0 }
@@ -246,7 +246,7 @@ extension MutableSpan where Element: ~Copyable {
246246

247247
@_alwaysEmitIntoClient
248248
public var indices: Range<Index> {
249-
unsafe Range(_uncheckedBounds: (0, _count))
249+
unsafe Range(_uncheckedBounds: (0, count))
250250
}
251251
}
252252

stdlib/public/core/Span/Span.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ extension Span where Element: ~Copyable {
391391
/// - Complexity: O(1)
392392
@_alwaysEmitIntoClient
393393
@_semantics("fixed_storage.get_count")
394-
public var count: Int { _count }
394+
public var count: Int { _assumeNonNegative(_count) }
395395

396396
/// A Boolean value indicating whether the span is empty.
397397
///
@@ -408,7 +408,7 @@ extension Span where Element: ~Copyable {
408408
/// - Complexity: O(1)
409409
@_alwaysEmitIntoClient
410410
public var indices: Range<Index> {
411-
unsafe Range(_uncheckedBounds: (0, _count))
411+
unsafe Range(_uncheckedBounds: (0, count))
412412
}
413413
}
414414

0 commit comments

Comments
 (0)