File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -4482,14 +4482,13 @@ internal enum _Variant${Self}Buffer<${TypeParametersDecl}> : _HashBuffer {
4482
4482
}
4483
4483
4484
4484
internal mutating func nativeRemoveAll() {
4485
- // FIXME(performance): if the buffer is non-uniquely referenced, we
4486
- // shouldn't be copying the elements into new buffer and then immediately
4487
- // deleting the elements. We should detect that the buffer is not uniquely
4488
- // referenced and allocate new empty buffer of appropriate capacity.
4485
+ if !isUniquelyReferenced() {
4486
+ asNative = NativeBuffer(minimumCapacity: asNative.capacity)
4487
+ return
4488
+ }
4489
4489
4490
- // We have already checked for the empty dictionary case, so we will always
4491
- // mutating the dictionary buffer. Request unique buffer.
4492
- _ = ensureUniqueNativeBuffer(asNative.capacity)
4490
+ // We have already checked for the empty dictionary case and unique
4491
+ // reference, so we will always mutate the dictionary buffer.
4493
4492
var nativeBuffer = asNative
4494
4493
4495
4494
for b in 0..<nativeBuffer.capacity {
You can’t perform that action at this time.
0 commit comments