diff options
| author | Michael Bebenita <[email protected]> | 2010-07-27 23:38:16 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2010-07-28 20:30:28 -0700 |
| commit | 60b0486c11f3c88e0a9aa13986ea338a54468bca (patch) | |
| tree | b73975eac835da03a61145a73b17f72c99a86d1a /src/rt/circular_buffer.h | |
| parent | Add a warning interface to rust_srv. (diff) | |
| download | rust-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.h | 4 |
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. |