/// <summary> /// Creates new instance with its own buffer. Create once and reuse to avoid GC. /// </summary> /// <param name="capacity">Count of 4 byte integers used as internal buffer.</param> public BitBufferWriter(u16 capacity = BitBuffer.DefaultU32Capacity, BitBufferOptions config = default) : this(new u32[capacity], config) { }
/// <summary> /// Creates new instance with its own buffer. /// </summary> /// <param name="buffer">Custom buffer.</param> public BitBufferWriter(u32[] buffer, BitBufferOptions config = default) : base(new u32ArrayMemory(buffer)) { // TODO: try inline config as struct to improve access performance? Test it via benchmark this.config = config.Equals(default) ? BitBufferOptions.Default : config;
/// <summary> /// Creates new instance with its own buffer. Create once and reuse to avoid GC. /// Call <see cref="CopyFrom"/> to reinitialize with copy of data. /// </summary> /// <param name="capacity">Count of 4 byte integers used as internal buffer.</param> public BitBufferReader(i32 capacity = BitBuffer.DefaultU32Capacity, BitBufferOptions config = default) : this(new u32[capacity], config) { }