Comment Comment by secondcoming If you enforce that the buffer size is a power of 2 you just use a mask to do the if (next_head == buffer.size()) next_head = 0; part parent secondcoming 7 months ago