perf: Simplify the ring-buffer code