logoalt Hacker News

JonChesterfieldyesterday at 2:46 PM2 repliesview on HN

If it's a power of two, you don't need the branch at all. Let the unsigned index wrap.


Replies

loegyesterday at 3:09 PM

You ultimately need a mask to access the correct slot in the ring. But it's true that you can leave unmasked values in your reader/writer indices.

dalvrosayesterday at 2:55 PM

Interesting, I've never heard about anybody using this. Maybe a bit unreadable? But yeah, should work :)

show 2 replies