File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -357,6 +357,7 @@ extension _StringGuts {
357
357
/// index, but it is guaranteed to never incorrectly return false. If all
358
358
/// loaded binaries were built in 5.7+, then this method is guaranteed to
359
359
/// always return the correct value.
360
+ @_alwaysEmitIntoClient
360
361
internal func hasMatchingEncoding( _ i: String . Index ) -> Bool {
361
362
( isForeign && i. _canBeUTF16) || ( !isForeign && i. _canBeUTF8)
362
363
}
Original file line number Diff line number Diff line change @@ -1050,6 +1050,7 @@ extension Substring {
1050
1050
_unchecked base: String . UnicodeScalarView , bounds: Range < Index >
1051
1051
) {
1052
1052
_slice = Slice ( base: base, bounds: bounds)
1053
+ _invariantCheck ( )
1053
1054
}
1054
1055
1055
1056
/// Creates an instance that slices `base` at `_bounds`.
@@ -1073,7 +1074,25 @@ extension Substring.UnicodeScalarView {
1073
1074
@_alwaysEmitIntoClient
1074
1075
@inline ( __always)
1075
1076
internal var _bounds : Range < Index > { _slice. _bounds }
1077
+ }
1078
+
1079
+ extension Substring . UnicodeScalarView {
1080
+ #if !INTERNAL_CHECKS_ENABLED
1081
+ @_alwaysEmitIntoClient @inline ( __always)
1082
+ internal func _invariantCheck( ) { }
1083
+ #else
1084
+ @_alwaysEmitIntoClient
1085
+ @inline ( never) @_effects ( releasenone)
1086
+ internal func _invariantCheck( ) {
1087
+ _internalInvariant ( endIndex <= _wholeGuts. endIndex)
1088
+ _internalInvariant (
1089
+ _wholeGuts. hasMatchingEncoding ( startIndex) &&
1090
+ _wholeGuts. hasMatchingEncoding ( endIndex) )
1091
+ _internalInvariant (
1092
+ startIndex. _isScalarAligned && endIndex. _isScalarAligned)
1093
+ _slice. _base. _invariantCheck ( )
1076
1094
}
1095
+ #endif // INTERNAL_CHECKS_ENABLED
1077
1096
}
1078
1097
1079
1098
extension Substring . UnicodeScalarView : BidirectionalCollection {
You can’t perform that action at this time.
0 commit comments