mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[csharp] Resize better if T is a class.
This commit is contained in:
parent
a5eed13591
commit
f2bac04e43
@ -90,7 +90,18 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ExposedList<T> Resize (int newSize) {
|
public ExposedList<T> Resize (int newSize) {
|
||||||
if (newSize > Items.Length) Array.Resize(ref Items, newSize);
|
int itemsLength = Items.Length;
|
||||||
|
var oldItems = Items;
|
||||||
|
if (newSize > itemsLength) {
|
||||||
|
Array.Resize(ref Items, newSize);
|
||||||
|
// var newItems = new T[newSize];
|
||||||
|
// Array.Copy(oldItems, newItems, Count);
|
||||||
|
// Items = newItems;
|
||||||
|
} else if (newSize > itemsLength) {
|
||||||
|
// Allow nulling of T reference type to allow GC.
|
||||||
|
for (int i = Count; i < itemsLength; i++)
|
||||||
|
oldItems[i] = default(T);
|
||||||
|
}
|
||||||
Count = newSize;
|
Count = newSize;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user