From c3820a61d9233642fb7c23f6d5364ea48a666e1a Mon Sep 17 00:00:00 2001 From: mlemanczyk Date: Sun, 25 Jun 2023 20:36:46 +0200 Subject: [PATCH] Code readability improvements - nullability checks disabled for memory blocks, to avoid hint suppression in code. --- Recyclable.Collections/RecyclableList.cs | 6 ++---- Recyclable.Collections/RecyclableLongList.cs | 8 ++------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Recyclable.Collections/RecyclableList.cs b/Recyclable.Collections/RecyclableList.cs index 9fde854..962e96c 100644 --- a/Recyclable.Collections/RecyclableList.cs +++ b/Recyclable.Collections/RecyclableList.cs @@ -13,7 +13,9 @@ namespace Recyclable.Collections public static explicit operator ReadOnlySpan(RecyclableList source) => new(source._memoryBlock, 0, source.Count); +#nullable disable protected T[] _memoryBlock; +#nullable restore // & WAS SLOWER // internal RecyclableCollectionVersion _version; // public RecyclableCollectionVersion Version => _version; @@ -508,9 +510,7 @@ namespace Recyclable.Collections if (NeedsClearing) { -#pragma warning disable CS8601 // In real use cases we'll never access it _memoryBlock[_count] = default; -#pragma warning restore CS8601 } _version++; @@ -537,9 +537,7 @@ namespace Recyclable.Collections if (NeedsClearing) { -#pragma warning disable CS8601 // In real use cases we'll never access it _memoryBlock[_count] = default; -#pragma warning restore CS8601 } _version++; diff --git a/Recyclable.Collections/RecyclableLongList.cs b/Recyclable.Collections/RecyclableLongList.cs index b1448d2..c345b4f 100644 --- a/Recyclable.Collections/RecyclableLongList.cs +++ b/Recyclable.Collections/RecyclableLongList.cs @@ -29,7 +29,9 @@ namespace Recyclable.Collections protected ArrayPool _memoryBlocksPool; protected ArrayPool _blockArrayPool; +#nullable disable internal T[][] _memoryBlocks; +#nullable restore private long _capacity; public long Capacity @@ -1215,9 +1217,7 @@ namespace Recyclable.Collections if (NeedsClearing) { -#pragma warning disable CS8601 // In real use cases we'll never access it _memoryBlocks[_nextItemBlockIndex][_nextItemIndex] = default; -#pragma warning restore CS8601 } _version++; @@ -1285,9 +1285,7 @@ namespace Recyclable.Collections if (NeedsClearing) { -#pragma warning disable CS8601 // In real use cases we'll never access it _memoryBlocks[_nextItemBlockIndex][_nextItemIndex] = default; -#pragma warning restore CS8601 } _version++; @@ -1325,9 +1323,7 @@ namespace Recyclable.Collections if (NeedsClearing) { -#pragma warning disable CS8601 // In real use cases we'll never access it _memoryBlocks[_nextItemBlockIndex][_nextItemIndex] = default; -#pragma warning restore CS8601 } _version++;