From e57fa3d5728202d8f4728d0ee727a77a240d30e0 Mon Sep 17 00:00:00 2001 From: mlemanczyk Date: Sun, 25 Jun 2023 02:25:32 +0200 Subject: [PATCH] Pure attribute added, where applicable. --- Recyclable.Collections/RecyclableList.Enumerator.cs | 6 ++++-- .../RecyclableList.VersionedEnumerator.cs | 6 ++++-- Recyclable.Collections/RecyclableLongList.Enumerator.cs | 4 ++++ .../RecyclableLongList.VersionedEnumerator.cs | 3 +++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Recyclable.Collections/RecyclableList.Enumerator.cs b/Recyclable.Collections/RecyclableList.Enumerator.cs index eb3a920..acaae28 100644 --- a/Recyclable.Collections/RecyclableList.Enumerator.cs +++ b/Recyclable.Collections/RecyclableList.Enumerator.cs @@ -1,4 +1,5 @@ using System.Collections; +using System.Diagnostics.Contracts; using System.Runtime.InteropServices; namespace Recyclable.Collections @@ -14,9 +15,9 @@ namespace Recyclable.Collections private readonly RecyclableList _list; #nullable disable - // [Pure] + [Pure] public readonly T Current => _list._memoryBlock[_currentItemIndex - 1]; - // [Pure] + [Pure] readonly object IEnumerator.Current => _list._memoryBlock[_currentItemIndex - 1]; #nullable restore @@ -37,6 +38,7 @@ namespace Recyclable.Collections _list = list; } + [Pure] public readonly void Dispose() { } diff --git a/Recyclable.Collections/RecyclableList.VersionedEnumerator.cs b/Recyclable.Collections/RecyclableList.VersionedEnumerator.cs index 30795e0..5e729f7 100644 --- a/Recyclable.Collections/RecyclableList.VersionedEnumerator.cs +++ b/Recyclable.Collections/RecyclableList.VersionedEnumerator.cs @@ -16,9 +16,10 @@ namespace Recyclable.Collections private readonly RecyclableList _list; #nullable disable - // [Pure] + [Pure] public readonly T Current => _enumeratorVersion == _list._version ? _list._memoryBlock[_currentItemIndex - 1] : throw new InvalidOperationException(); - // [Pure] + + [Pure] readonly object IEnumerator.Current => _enumeratorVersion == _list._version ? _list._memoryBlock[_currentItemIndex - 1] : throw new InvalidOperationException(); #nullable restore @@ -47,6 +48,7 @@ namespace Recyclable.Collections _enumeratorVersion = list._version; } + [Pure] public readonly void Dispose() { } diff --git a/Recyclable.Collections/RecyclableLongList.Enumerator.cs b/Recyclable.Collections/RecyclableLongList.Enumerator.cs index 2f28434..01c94dd 100644 --- a/Recyclable.Collections/RecyclableLongList.Enumerator.cs +++ b/Recyclable.Collections/RecyclableLongList.Enumerator.cs @@ -1,4 +1,5 @@ using System.Collections; +using System.Diagnostics.Contracts; namespace Recyclable.Collections { @@ -19,6 +20,8 @@ namespace Recyclable.Collections #nullable disable private T _current; #nullable restore + + [Pure] public readonly T Current => _current; public bool MoveNext() @@ -52,6 +55,7 @@ namespace Recyclable.Collections } #nullable disable + [Pure] readonly object IEnumerator.Current => _current; #nullable restore diff --git a/Recyclable.Collections/RecyclableLongList.VersionedEnumerator.cs b/Recyclable.Collections/RecyclableLongList.VersionedEnumerator.cs index 843c46a..64e554a 100644 --- a/Recyclable.Collections/RecyclableLongList.VersionedEnumerator.cs +++ b/Recyclable.Collections/RecyclableLongList.VersionedEnumerator.cs @@ -24,6 +24,8 @@ public partial class RecyclableLongList : IRecyclableVersionedLongList #nullable disable private T _current; #nullable restore + + [Pure] public readonly T Current => _enumeratorVersion == _list._version ? _current : throw new InvalidOperationException(); private readonly ulong _enumeratorVersion; @@ -65,6 +67,7 @@ public partial class RecyclableLongList : IRecyclableVersionedLongList } #nullable disable + [Pure] readonly object IEnumerator.Current => _enumeratorVersion == _list._version ? _current : throw new InvalidOperationException(); #nullable restore