Skip to content

Commit f6f36fa

Browse files
committed
[stdlib] simplify indexing
1 parent 2bc053f commit f6f36fa

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

stdlib/public/core/Slice.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,8 @@ extension Slice {
237237
if let (_, copied) = self.withContiguousStorageIfAvailable({
238238
$0._copyContents(initializing: buffer)
239239
}) {
240-
let distance = buffer.distance(from: buffer.startIndex, to: copied)
241-
let i = index(startIndex, offsetBy: distance)
242-
return (Iterator(_elements: self, _position: i), copied)
240+
let position = index(startIndex, offsetBy: copied)
241+
return (Iterator(_elements: self, _position: position), copied)
243242
}
244243

245244
return _copySequenceContents(initializing: buffer)

0 commit comments

Comments
 (0)