From bc6b3adc6c5de9b50639f3e5e693d5aa8f342d41 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Wed, 26 Mar 2014 13:00:52 +0200 Subject: [PATCH] Small tweak to previous (convert multiplication to bitshift) --- src/library/triplebuffer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/library/triplebuffer.cpp b/src/library/triplebuffer.cpp index 01a7c215..8ecc4d1f 100644 --- a/src/library/triplebuffer.cpp +++ b/src/library/triplebuffer.cpp @@ -36,7 +36,7 @@ void logic::put_read() throw(std::logic_error) unsigned logic::get_write() throw() { - const unsigned magic = 0x1099; + const unsigned magic = 0x010219; threads::alock h(lock); if(count_write > 0) { //We already are writing => The same as previously. @@ -45,7 +45,7 @@ unsigned logic::get_write() throw() } else { //We are beginning a new write => Pick one that isn't last_complete nor current_read. count_write++; - unsigned tmp = 6 * last_complete + 2 * current_read; + unsigned tmp = ((last_complete << 2) | current_read) << 1; current_write = (magic >> tmp) & 3; return current_write; }