Merge branch 'master' of https://github.com/Cysharp/ObservableCollections
This commit is contained in:
commit
de8cbeb795
@ -33,8 +33,10 @@ namespace ObservableCollections.Internal
|
|||||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||||
void EnsureCapacity()
|
void EnsureCapacity()
|
||||||
{
|
{
|
||||||
var newArray = array.AsSpan().ToArray();
|
var oldArray = array!;
|
||||||
ArrayPool<T>.Shared.Return(array!, RuntimeHelpersEx.IsReferenceOrContainsReferences<T>());
|
var newArray = ArrayPool<T>.Shared.Rent(oldArray.Length * 2);
|
||||||
|
Array.Copy(oldArray, newArray, oldArray.Length);
|
||||||
|
ArrayPool<T>.Shared.Return(oldArray, RuntimeHelpersEx.IsReferenceOrContainsReferences<T>());
|
||||||
array = newArray;
|
array = newArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user