Skip to content

Commit 243a89e

Browse files
committed
NSRange: replace init(_:in:) with Darwin implementation
1 parent 7e605c3 commit 243a89e

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

Foundation/NSRange.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,7 @@ extension NSRange {
260260
public init<R: RangeExpression, S: StringProtocol>(_ region: R, in target: S)
261261
where R.Bound == S.Index {
262262
let r = region.relative(to: target)
263-
let u = target.utf16
264-
self = NSRange(
265-
location: u.distance(from: target.startIndex, to: r.lowerBound),
266-
length: u.distance(from: r.lowerBound, to: r.upperBound)
267-
)
263+
self.init(target._toUTF16Offsets(r))
268264
}
269265

270266
@available(swift, deprecated: 4, renamed: "Range.init(_:)")

0 commit comments

Comments
 (0)