Skip to content

Commit 282a140

Browse files
committed
[stdlib] U[R]BP: Restore compile-time condition lost with removed precondition
1 parent 9336821 commit 282a140

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

stdlib/public/core/UnsafeBufferPointer.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ extension Unsafe${Mutable}BufferPointer {
414414
count == 0 || start != nil,
415415
"Unsafe${Mutable}BufferPointer has a nil start and nonzero count")
416416
_position = start
417-
self.count = count
417+
self.count = _assumeNonNegative(count)
418418
}
419419

420420
@inlinable // unsafe-performance

stdlib/public/core/UnsafeRawBufferPointer.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ extension Unsafe${Mutable}RawBufferPointer {
436436
_debugPrecondition(count == 0 || start != nil,
437437
"${Self} has a nil start and nonzero count")
438438
_position = start
439-
_end = start.map { $0 + count }
439+
_end = start.map { $0 + _assumeNonNegative(count) }
440440
}
441441

442442
/// Creates a new buffer over the same memory as the given buffer.

0 commit comments

Comments
 (0)