boost ring queue: use % to wrap the index

For power of 2, it is replaced with a single and instruction. If it potentially faster
than branch. But it worths a benchmark
This commit is contained in:
Gregory Hainaut 2017-01-05 08:40:23 +01:00
parent 725aaccf5c
commit 8779583bdb
1 changed files with 4 additions and 3 deletions

View File

@ -91,11 +91,12 @@ public:
{
size_t ret = arg + 1;
#if 0
// Initial boost code
while (unlikely(ret >= max_size))
#else
while (ret >= max_size)
#endif
ret -= max_size;
#else
ret %= max_size;
#endif
return ret;
}