File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -109,11 +109,13 @@ extension String.UTF16View: BidirectionalCollection {
109
109
let iOffset = _getOffset ( for: i)
110
110
let limitOffset = _getOffset ( for: limit)
111
111
112
- if _slowPath ( limitOffset < iOffset + n) {
113
- // If distance > 0, limit has no effect if it is less than i. Likewise,
114
- // if distance < 0, limit has no effect if it is greater than i.
115
- if n > 0 && limitOffset >= iOffset { return nil }
116
- if n < 0 && limitOffset <= iOffset { return nil }
112
+ // If distance < 0, limit has no effect if it is greater than i.
113
+ if _slowPath ( n < 0 && limit <= i && limitOffset > iOffset + n) {
114
+ return nil
115
+ }
116
+ // If distance > 0, limit has no effect if it is less than i. Likewise,
117
+ if _slowPath ( n >= 0 && limit >= i && limitOffset < iOffset + n) {
118
+ return nil
117
119
}
118
120
119
121
let result = _getIndex ( for: iOffset + n)
You can’t perform that action at this time.
0 commit comments