mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[stdlib] Replace "sanityCheck" with "internalInvariant" (#20616)
* Replace "sanityCheck" with "internalInvariant"
This commit is contained in:
@@ -615,7 +615,7 @@ extension UTF8.CodeUnit : _StringElement {
|
||||
@inlinable
|
||||
public // @testable
|
||||
static func _toUTF16CodeUnit(_ x: UTF8.CodeUnit) -> UTF16.CodeUnit {
|
||||
_sanityCheck(x <= 0x7f, "should only be doing this with ASCII")
|
||||
_internalInvariant(x <= 0x7f, "should only be doing this with ASCII")
|
||||
return UTF16.CodeUnit(truncatingIfNeeded: x)
|
||||
}
|
||||
@inlinable
|
||||
@@ -623,7 +623,7 @@ extension UTF8.CodeUnit : _StringElement {
|
||||
static func _fromUTF16CodeUnit(
|
||||
_ utf16: UTF16.CodeUnit
|
||||
) -> UTF8.CodeUnit {
|
||||
_sanityCheck(utf16 <= 0x7f, "should only be doing this with ASCII")
|
||||
_internalInvariant(utf16 <= 0x7f, "should only be doing this with ASCII")
|
||||
return UTF8.CodeUnit(truncatingIfNeeded: utf16)
|
||||
}
|
||||
}
|
||||
@@ -871,9 +871,9 @@ extension Unicode.Scalar {
|
||||
/// precondition checks for code point validity.
|
||||
@inlinable
|
||||
internal init(_unchecked value: UInt32) {
|
||||
_sanityCheck(value < 0xD800 || value > 0xDFFF,
|
||||
_internalInvariant(value < 0xD800 || value > 0xDFFF,
|
||||
"high- and low-surrogate code points are not valid Unicode scalar values")
|
||||
_sanityCheck(value <= 0x10FFFF, "value is outside of Unicode codespace")
|
||||
_internalInvariant(value <= 0x10FFFF, "value is outside of Unicode codespace")
|
||||
|
||||
self._value = value
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user