As of commit e2cbbd0 I count at least 4 separate ring buffer implementations:
std.fifo.LinearFifo - most generic, longest existing.
std.RingBuffer - used only by zstd implementation but part of the public std API.
lib/std/compress/flate/CircularBuffer.zig - internal to inflate implementation.
lib/std/compress/lzma/decode/lzbuffer.zig - internal to lzma implementation.
The current std.RingBuffer implementation is not generic and only supports buffers of u8. It also only supports fixed-length ring buffers while std.fifo.LinearFifo supports a dynamically growable buffer. I think one of two things needs to happen here:
std.fifo.linearFifo and std.RingBuffer need to make clear the tradeoffs between the APIs/implementations and present a meaningful choice between the two.
- Either
std.fifo.linearFifo or std.RingBuffer should have its functionality merged into the other and be deleted.
The flate and lzma internal ring buffer implementations are both specialized to the code using them which is fine. However, I suspect they could benefit by using a more generic implementation as a backing data structure.
I don't know exactly what the resolution to this issue should look like, quality API design is quite tricky. However, I think it is important to address before stabilizing the standard library.
As of commit e2cbbd0 I count at least 4 separate ring buffer implementations:
std.fifo.LinearFifo- most generic, longest existing.std.RingBuffer- used only by zstd implementation but part of the public std API.lib/std/compress/flate/CircularBuffer.zig- internal to inflate implementation.lib/std/compress/lzma/decode/lzbuffer.zig- internal to lzma implementation.The current
std.RingBufferimplementation is not generic and only supports buffers ofu8. It also only supports fixed-length ring buffers whilestd.fifo.LinearFifosupports a dynamically growable buffer. I think one of two things needs to happen here:std.fifo.linearFifoandstd.RingBufferneed to make clear the tradeoffs between the APIs/implementations and present a meaningful choice between the two.std.fifo.linearFifoorstd.RingBuffershould have its functionality merged into the other and be deleted.The
flateandlzmainternal ring buffer implementations are both specialized to the code using them which is fine. However, I suspect they could benefit by using a more generic implementation as a backing data structure.I don't know exactly what the resolution to this issue should look like, quality API design is quite tricky. However, I think it is important to address before stabilizing the standard library.