aboutsummaryrefslogtreecommitdiff
path: root/src/rt/circular_buffer.h
diff options
context:
space:
mode:
authorMichael Bebenita <[email protected]>2010-07-27 23:38:16 -0700
committerGraydon Hoare <[email protected]>2010-07-28 20:30:28 -0700
commit60b0486c11f3c88e0a9aa13986ea338a54468bca (patch)
treeb73975eac835da03a61145a73b17f72c99a86d1a /src/rt/circular_buffer.h
parentAdd a warning interface to rust_srv. (diff)
downloadrust-60b0486c11f3c88e0a9aa13986ea338a54468bca.tar.xz
rust-60b0486c11f3c88e0a9aa13986ea338a54468bca.zip
Make circular buffer use only power-of-two sizes, cheaper arithmetic.
Diffstat (limited to 'src/rt/circular_buffer.h')
-rw-r--r--src/rt/circular_buffer.h4
1 files changed, 3 insertions, 1 deletions
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.