File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -750,9 +750,13 @@ internal struct _UnsafePartiallyInitializedContiguousArrayBuffer<Element> {
750
750
_uninitializedCount: newCapacity, minimumCapacity: 0 )
751
751
p = newResult. firstElementAddress + result. capacity
752
752
remainingCapacity = newResult. capacity - result. capacity
753
- newResult. firstElementAddress. moveInitialize (
754
- from: result. firstElementAddress, count: result. capacity)
755
- result. count = 0
753
+ if !result. isEmpty {
754
+ // This check prevents a data race writting to _swiftEmptyArrayStorage
755
+ // Since count is always 0 there, this code does nothing anyway
756
+ newResult. firstElementAddress. moveInitialize (
757
+ from: result. firstElementAddress, count: result. capacity)
758
+ result. count = 0
759
+ }
756
760
( result, newResult) = ( newResult, result)
757
761
}
758
762
addWithExistingCapacity ( element)
You can’t perform that action at this time.
0 commit comments