From 60b0486c11f3c88e0a9aa13986ea338a54468bca Mon Sep 17 00:00:00 2001 From: Michael Bebenita Date: Tue, 27 Jul 2010 23:38:16 -0700 Subject: Make circular buffer use only power-of-two sizes, cheaper arithmetic. --- src/rt/circular_buffer.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/rt/circular_buffer.h') diff --git a/src/rt/circular_buffer.h b/src/rt/circular_buffer.h index 2ebf23b0..3d11b37f 100644 --- a/src/rt/circular_buffer.h +++ b/src/rt/circular_buffer.h @@ -20,7 +20,9 @@ public: bool is_empty(); private: - // Size of the buffer in bytes. + // Size of the buffer in bytes, should always be a power of two so that + // modulo arithmetic (x % _buffer_sz) can optimized away with + // (x & (_buffer_sz - 1)). size_t _buffer_sz; // Size of the data unit in bytes. -- cgit v1.2.3