77 * PROGRAMMER: Peter Geinitz (Wayfarer)
88 */
99
10+ // ReSharper disable UnusedMember.Global
11+
1012using MemoryManager . Core ;
1113using System . Runtime . CompilerServices ;
1214
@@ -57,16 +59,12 @@ public sealed class ArenaList<T> : IDisposable where T : unmanaged
5759 /// <summary>
5860 /// Initializes a new instance of the <see cref="ArenaList{T}" /> class.
5961 /// </summary>
60- < << << << HEAD
6162 /// <param name="arena">The arena.</param>
6263 /// <param name="initialCapacity">The initial capacity.</param>
6364 /// <param name="priority">The priority.</param>
6465 /// <param name="hints">The hints.</param>
65- public ArenaList( IMemoryAllocator arena , int initialCapacity = 8 , AllocationPriority priority = AllocationPriority . Normal , AllocationHints hints = AllocationHints . None )
66- == == == =
6766 public ArenaList ( MemoryArena arena , int initialCapacity = 8 ,
6867 AllocationPriority priority = AllocationPriority . Normal , AllocationHints hints = AllocationHints . None )
69- >>> >>> > f41cf23e1c66b3d2e4e393356f32f92443e0ab03
7068 {
7169 if ( initialCapacity <= 0 ) initialCapacity = 8 ;
7270
@@ -109,12 +107,9 @@ public void Add(T item)
109107 public ref T Get ( int index )
110108 {
111109 if ( index < 0 || index >= Count )
112- < << << << HEAD
113- throw new IndexOutOfRangeException ( $ "Index { index } is outside active boundaries.") ;
114- = == == ==
115110 throw new IndexOutOfRangeException (
116111 $ "Index { index } is outside the active boundaries of the ArenaList (Count: { Count } ).") ;
117- > >>> >>> f41cf23e1c66b3d2e4e393356f32f92443e0ab03
112+
118113
119114 var span = _arena . GetSpan < T > ( _handle , _capacity ) ;
120115 return ref span [ index ] ;
@@ -126,14 +121,13 @@ public ref T Get(int index)
126121 public void Clear ( ) => Count = 0 ;
127122
128123 /// <summary>
129- /// Ases the span .
124+ /// Converts the active portion of the internal buffer to a <see cref="Span{T}"/> for zero-allocation access .
130125 /// </summary>
131126 /// <returns></returns>
132127 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
133128 public Span < T > AsSpan ( )
134129 {
135- if ( Count == 0 ) return Span < T > . Empty ;
136- return _arena . GetSpan < T > ( _handle , _capacity ) . Slice ( 0 , Count ) ;
130+ return Count == 0 ? Span < T > . Empty : _arena . GetSpan < T > ( _handle , _capacity ) . Slice ( 0 , Count ) ;
137131 }
138132
139133 /// <summary>
@@ -162,16 +156,16 @@ private void Grow()
162156 _capacity = newCapacity ;
163157 }
164158
159+ /// <inheritdoc />
165160 /// <summary>
166161 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
167162 /// </summary>
168163 public void Dispose ( )
169164 {
170- if ( ! _handle . IsInvalid )
171- {
172- _arena . Free ( _handle ) ;
173- _handle = default ;
174- }
165+ if ( _handle . IsInvalid ) return ;
166+
167+ _arena . Free ( _handle ) ;
168+ _handle = default ;
175169 }
176170 }
177171}
0 commit comments