Skip to content

Commit 74a8254

Browse files
karwalorentey
authored andcommitted
Make UBP nil/count checks debug-mode only
Every other Unsafe(Mutable)BufferPointer precondition in this file is debug-mode only. This information is already part of the documentation for this function, and it's really hard to get rid of these branches and traps otherwise.
1 parent 413352b commit 74a8254

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

stdlib/public/core/UnsafeBufferPointer.swift.gyb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,9 @@ extension Unsafe${Mutable}BufferPointer {
401401
public init(
402402
@_nonEphemeral start: Unsafe${Mutable}Pointer<Element>?, count: Int
403403
) {
404-
_precondition(
404+
_debugPrecondition(
405405
count >= 0, "Unsafe${Mutable}BufferPointer with negative count")
406-
_precondition(
406+
_debugPrecondition(
407407
count == 0 || start != nil,
408408
"Unsafe${Mutable}BufferPointer has a nil start and nonzero count")
409409
_position = start

0 commit comments

Comments
 (0)