mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 17:15:31 +02:00
Better ring index compute
This commit is contained in:
parent
7e4999b717
commit
c0b8f83ca0
1 changed files with 2 additions and 2 deletions
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
void insert(const T& entry) {
|
||||
// increment newest entry index cyclically
|
||||
_newestEntryAtIndex = (_newestEntryAtIndex == _size - 1) ? 0 : _newestEntryAtIndex + 1;
|
||||
_newestEntryAtIndex = (_newestEntryAtIndex + 1) % _size;
|
||||
|
||||
// insert new entry
|
||||
_buffer[_newestEntryAtIndex] = entry;
|
||||
|
@ -57,7 +57,7 @@ public:
|
|||
// std::unique_ptr need to be passed as an rvalue ref and moved into the vector
|
||||
void insert(T&& entry) {
|
||||
// increment newest entry index cyclically
|
||||
_newestEntryAtIndex = (_newestEntryAtIndex == _size - 1) ? 0 : _newestEntryAtIndex + 1;
|
||||
_newestEntryAtIndex = (_newestEntryAtIndex + 1) % _size;
|
||||
|
||||
// insert new entry
|
||||
_buffer[_newestEntryAtIndex] = std::move(entry);
|
||||
|
|
Loading…
Reference in a new issue