Hacker News new | ask | show | jobs
by ufo 457 days ago
I'd love to see performance numbers for this, if they're available. My hunch is that indexing cost would be about the same.
1 comments

They both have an offset, but ring buffers aren’t contiguous so they also need a branch or modulus to handle wrap around. Either can be cheap, but clearly that is strictly more costly than not having the extra operation (even if very little). Only matters for random indexing also, since for mutation the situation is swapped
There are many situations where those little differences completely vanish because of instruction pipelining. Only way to know is to actually measure it.