File tree Expand file tree Collapse file tree 3 files changed +3
-2
lines changed
test/stdlib/Inputs/NSSlowString Expand file tree Collapse file tree 3 files changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ internal func _cocoaStringUTF8Count(
95
95
_ target: _CocoaString ,
96
96
range: Range < Int >
97
97
) -> Int ? {
98
+ if range. isEmpty { return 0 }
98
99
var count = 0
99
100
let len = _stdlib_binary_CFStringGetLength ( target)
100
101
let converted = _swift_stdlib_CFStringGetBytes (
Original file line number Diff line number Diff line change @@ -505,7 +505,7 @@ extension String.UTF8View {
505
505
// _cocoaStringUTF8Count gave us the scalar aligned count, but we still
506
506
// need to compensate for sub-scalar indexing, e.g. if `i` is in the
507
507
// middle of a two-byte UTF8 scalar.
508
- let refinedCount = count - ( i. transcodedOffset + j. transcodedOffset)
508
+ let refinedCount = ( count - i. transcodedOffset) + j. transcodedOffset
509
509
_internalInvariant ( refinedCount == _distance ( from: i, to: j) )
510
510
return refinedCount
511
511
}
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ - (NSUInteger)length {
22
22
return self.stringHolder .length ;
23
23
}
24
24
25
- - (id )copy {
25
+ - (id )copyWithZone : ( NSZone *) unused {
26
26
return self;
27
27
}
28
28
You can’t perform that action at this time.
0 commit comments