/ src / Ryujinx.Graphics.Texture / Astc / IntegerSequence.cs
IntegerSequence.cs
 1  using System;
 2  using System.Diagnostics;
 3  using System.Runtime.CompilerServices;
 4  using System.Runtime.InteropServices;
 5  
 6  namespace Ryujinx.Graphics.Texture.Astc
 7  {
 8      [StructLayout(LayoutKind.Sequential, Size = IntegerEncoded.StructSize * Capacity + sizeof(int))]
 9      internal struct IntegerSequence
10      {
11          private const int Capacity = 100;
12  
13          private int _length;
14          private IntegerEncoded _start;
15  
16          public Span<IntegerEncoded> List => MemoryMarshal.CreateSpan(ref _start, _length);
17  
18          public void Reset() => _length = 0;
19  
20          [MethodImpl(MethodImplOptions.AggressiveInlining)]
21          public void Add(ref IntegerEncoded item)
22          {
23              Debug.Assert(_length < Capacity);
24  
25              int oldLength = _length;
26              _length++;
27  
28              List[oldLength] = item;
29          }
30      }
31  }