@@ -113,9 +113,8 @@ public struct Substring: Sendable {
113
113
@usableFromInline // This used to be @inlinable before 5.7
114
114
@available ( * , deprecated) // Use `init(_unchecked:)` in new code.
115
115
internal init ( _ slice: Slice < String > ) {
116
- let r = slice. base. _guts. validateScalarRange (
117
- slice. startIndex ..< slice. endIndex)
118
- self . _slice = Slice ( base: slice. base, bounds: r)
116
+ let r = slice. _base. _guts. validateScalarRange ( slice. _bounds)
117
+ self . _slice = Slice ( base: slice. _base, bounds: r)
119
118
_invariantCheck ( )
120
119
}
121
120
@@ -137,19 +136,13 @@ extension Substring {
137
136
public var base : String { return _slice. _base }
138
137
139
138
@inlinable @inline ( __always)
140
- internal var _wholeGuts : _StringGuts { return _slice. _base. _guts }
139
+ internal var _wholeGuts : _StringGuts { _slice. _base. _guts }
141
140
142
141
@inlinable @inline ( __always)
143
- internal var _offsetRange : Range < Int > {
144
- let lower = _slice. _startIndex. _encodedOffset
145
- let upper = _slice. _endIndex. _encodedOffset
146
- return Range ( _uncheckedBounds: ( lower, upper) )
147
- }
142
+ internal var _offsetRange : Range < Int > { _slice. _bounds. _encodedOffsetRange }
148
143
149
144
@inlinable @inline ( __always)
150
- internal var _bounds : Range < Index > {
151
- Range ( _uncheckedBounds: ( startIndex, endIndex) )
152
- }
145
+ internal var _bounds : Range < Index > { _slice. _bounds }
153
146
}
154
147
155
148
extension Substring {
@@ -746,9 +739,7 @@ extension Substring {
746
739
internal var _base : String . UTF8View { _slice. _base }
747
740
748
741
@_alwaysEmitIntoClient @inline ( __always)
749
- internal var _bounds : Range < Index > {
750
- Range ( _uncheckedBounds: ( _slice. _startIndex, _slice. _endIndex) )
751
- }
742
+ internal var _bounds : Range < Index > { _slice. _bounds }
752
743
}
753
744
}
754
745
@@ -912,9 +903,7 @@ extension Substring {
912
903
internal var _base : String . UTF16View { _slice. _base }
913
904
914
905
@_alwaysEmitIntoClient @inline ( __always)
915
- internal var _bounds : Range < Index > {
916
- Range ( _uncheckedBounds: ( _slice. _startIndex, _slice. _endIndex) )
917
- }
906
+ internal var _bounds : Range < Index > { _slice. _bounds }
918
907
}
919
908
}
920
909
@@ -1075,21 +1064,15 @@ extension Substring {
1075
1064
}
1076
1065
1077
1066
extension Substring . UnicodeScalarView {
1078
- @_alwaysEmitIntoClient
1079
- @inline ( __always)
1067
+ @_alwaysEmitIntoClient @inline ( __always)
1080
1068
internal var _wholeGuts : _StringGuts { _slice. _base. _guts }
1081
1069
1082
1070
@inline ( __always)
1083
- internal var _offsetRange : Range < Int > {
1084
- let lower = _slice. _startIndex. _encodedOffset
1085
- let upper = _slice. _endIndex. _encodedOffset
1086
- return Range ( _uncheckedBounds: ( lower, upper) )
1087
- }
1071
+ internal var _offsetRange : Range < Int > { _slice. _bounds. _encodedOffsetRange }
1088
1072
1089
1073
@_alwaysEmitIntoClient
1090
1074
@inline ( __always)
1091
- internal var _bounds : Range < Index > {
1092
- Range ( _uncheckedBounds: ( startIndex, endIndex) )
1075
+ internal var _bounds : Range < Index > { _slice. _bounds }
1093
1076
}
1094
1077
}
1095
1078
0 commit comments