diff options
| author | Brian Anderson <[email protected]> | 2011-01-08 18:19:55 -0500 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-01-10 11:31:33 -0800 |
| commit | 295c54e10f587a56dfec95ca3a3aee0f9fd721a2 (patch) | |
| tree | 74f9f227ed056f8132424989106019f534c3e0da /src/rt/circular_buffer.h | |
| parent | Remove unused variable in circular_buffer tests (diff) | |
| download | rust-295c54e10f587a56dfec95ca3a3aee0f9fd721a2.tar.xz rust-295c54e10f587a56dfec95ca3a3aee0f9fd721a2.zip | |
Remove the assumption that circular_buffer's buffer has a power of two size
It was not obvious how to make this implementation work when the unit size
was not also a power of two, so for now just make the buffer size a multiple
of the unit size so it can pass all the tests.
Diffstat (limited to 'src/rt/circular_buffer.h')
| -rw-r--r-- | src/rt/circular_buffer.h | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/rt/circular_buffer.h b/src/rt/circular_buffer.h index 40fb1e24..d44721b5 100644 --- a/src/rt/circular_buffer.h +++ b/src/rt/circular_buffer.h @@ -7,8 +7,8 @@ class circular_buffer : public dom_owned<circular_buffer> { - static const size_t INITIAL_CIRCULAR_BUFFFER_SIZE_IN_UNITS = 8; - static const size_t MAX_CIRCULAR_BUFFFER_SIZE = 1 << 24; + static const size_t INITIAL_CIRCULAR_BUFFER_SIZE_IN_UNITS = 8; + static const size_t MAX_CIRCULAR_BUFFER_SIZE = 1 << 24; public: rust_dom *dom; @@ -24,12 +24,7 @@ public: size_t size(); private: - // Initial size of the buffer in bytes. - size_t _initial_sz; - - // 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 of the buffer in bytes. size_t _buffer_sz; // Byte offset within the buffer where to read the next unit of data. @@ -42,4 +37,15 @@ private: uint8_t *_buffer; }; +// +// Local Variables: +// mode: C++ +// fill-column: 78; +// indent-tabs-mode: nil +// c-basic-offset: 4 +// buffer-file-coding-system: utf-8-unix +// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'"; +// End: +// + #endif /* CIRCULAR_BUFFER_H */ |