Cleanup. Commented out code removed.

This commit is contained in:
mlemanczyk committed 2023-07-01 15:01:40 +02:00
1 parent 748f206c39
commit f23e9054e5
1 file changed
-33
-33
View File
@@ -6,7 +6,6 @@ namespace Recyclable.Collections
[Serializable] [Serializable]
public sealed partial class RecyclableList<T> : IList<T>, IReadOnlyList<T>, IDisposable public sealed partial class RecyclableList<T> : IList<T>, IReadOnlyList<T>, IDisposable
{ {
// private static readonly T[] _emptyMemoryBlock = new T[0];
private static readonly bool NeedsClearing = !typeof(T).IsValueType; private static readonly bool NeedsClearing = !typeof(T).IsValueType;
public static explicit operator ReadOnlySpan<T>(RecyclableList<T> source) => new(source._memoryBlock, 0, source.Count); public static explicit operator ReadOnlySpan<T>(RecyclableList<T> source) => new(source._memoryBlock, 0, source.Count);
@@ -173,7 +172,6 @@ namespace Recyclable.Collections
if (_capacity != value) if (_capacity != value)
{ {
RecyclableListHelpers<T>.ResizeAndCopy(this, value); RecyclableListHelpers<T>.ResizeAndCopy(this, value);
// _capacity = _memoryBlock.Length;
_version++; _version++;
} }
} }
@@ -189,16 +187,6 @@ namespace Recyclable.Collections
{ {
// TODO: Measure performance // TODO: Measure performance
// ArrayPool<T> arrayPool = _arrayPool; // ArrayPool<T> arrayPool = _arrayPool;
// & WAS SLOWER
// int newSize = _capacity << 1;
// & WAS SLOWER
// if ((_capacity <<= 1) < RecyclableDefaults.MinPooledArrayLength)
// {
// Array.Resize(ref _memoryBlock, _capacity);
// // _capacity <<= 1;
// return;
// }
// TODO: Measure performance after RecyclableArrayPool is reworked // TODO: Measure performance after RecyclableArrayPool is reworked
// T[] newMemoryBlock = RecyclableListHelpers<T>._arrayPool.Rent(_capacity <<= 1); // T[] newMemoryBlock = RecyclableListHelpers<T>._arrayPool.Rent(_capacity <<= 1);
T[] newMemoryBlock = (_capacity <<= 1) >= RecyclableDefaults.MinPooledArrayLength T[] newMemoryBlock = (_capacity <<= 1) >= RecyclableDefaults.MinPooledArrayLength
@@ -208,8 +196,6 @@ namespace Recyclable.Collections
// & WAS SLOWER WITHOUT // & WAS SLOWER WITHOUT
T[] oldMemoryBlock = _memoryBlock; T[] oldMemoryBlock = _memoryBlock;
new Span<T>(oldMemoryBlock).CopyTo(newMemoryBlock); new Span<T>(oldMemoryBlock).CopyTo(newMemoryBlock);
// & WAS SLOWER
// Array.Copy(oldMemoryBlock, newMemoryBlock, oldMemoryBlock.Length);
if (oldMemoryBlock.Length >= RecyclableDefaults.MinPooledArrayLength) if (oldMemoryBlock.Length >= RecyclableDefaults.MinPooledArrayLength)
{ {
@@ -233,27 +219,8 @@ namespace Recyclable.Collections
if (_count == _capacity) if (_count == _capacity)
{ {
ResizeAndCopy(); ResizeAndCopy();
// & WAS SLOWER
// new Span<T>(_memoryBlock)[_count++] = item;
// }
// else
// if (_capacity == _count)
// {
// break;
// case false:
// newCapacity = requestedCapacity;
// list._memoryBlock = Resize(list, newCapacity);
// break;
// }
// var newCapacity = list._memoryBlock.Length;
// _capacity = _memoryBlock.Length;
} }
// & WAS SLOWER
// new Span<T>(_memoryBlock)[_count++] = item;
// new Span<T>(_memoryBlock, _count++, 1)[0] = item;
_memoryBlock[_count++] = item; _memoryBlock[_count++] = item;
_version++; _version++;
} }