mirror of
https://github.com/apple/swift-collections
synced 2026-11-24 04:27:53 +00:00
Merge pull request #755 from hamed75kazemii/fix-replace-subrange-multiple-spans
Copy every source span in replaceSubrange(copying:)
This commit is contained in:
1 file changed
+6
-3
@@ -578,9 +578,12 @@ where
|
||||
var c = items.count
|
||||
var i = items.startIndex
|
||||
let range = self.replaceSubrange(subrange, addingCount: c) { target in
|
||||
let source = items.nextSpan(after: &i, maxCount: target.freeCapacity)
|
||||
target._append(copying: source)
|
||||
c -= source.count
|
||||
while !target.isFull {
|
||||
let source = items.nextSpan(after: &i, maxCount: target.freeCapacity)
|
||||
if source.isEmpty { break }
|
||||
target._append(copying: source)
|
||||
c -= source.count
|
||||
}
|
||||
}
|
||||
precondition(c == 0, "Invalid RangeReplaceableContainer")
|
||||
return range
|
||||
|
||||
Reference in new issue
Block a user