History

Ensure a C++ object exists for all static const members of structs or create constexpr functions. - This is an attempt to adhere to the letter of the C++ specification.

arr committed 9 years ago

Commit af5c7a91 parent 4d839d714 files · +86 −64Browse files

Showing the changes to src/include/buffered_reader.h (1 of 14 files). Show all

Unified · Split

src/include/buffered_reader.h+3−6
@@ -20,12 +20,9 @@ namespace disvm · 19 unmodified lines
20 {20 {
21 class buffered_reader_t21 class buffered_reader_t
22 {22 {
23 private: // static
24 static const std::size_t buffer_size = 64 * 1024; // 64k is an optimization for the Windows filesystem manager
25
26 public:23 public:
27 buffered_reader_t(std::istream &stream)24 buffered_reader_t(std::istream &stream)
28 : _buffer(buffered_reader_t::buffer_size)25 : _buffer(64 * 1024) // 64k is an optimization for the Windows filesystem manager
29 , _current_index{ 0 }26 , _current_index{ 0 }
30 , _current_size{ 0 }27 , _current_size{ 0 }
31 , _stream{ stream }28 , _stream{ stream }
@@ -141,10 +138,10 @@ namespace disvm · 109 unmodified lines
141 if (_stream.fail())138 if (_stream.fail())
142 return 0;139 return 0;
143 140
144 _stream.read(_buffer.data(), buffered_reader_t::buffer_size);141 _stream.read(_buffer.data(), _buffer.size());
145 142
146 // If the stream has failed, set the current size, otherwise the buffer size143 // If the stream has failed, set the current size, otherwise the buffer size
147 _current_size = _stream.fail() ? static_cast<std::size_t>(_stream.gcount()) : buffered_reader_t::buffer_size;144 _current_size = _stream.fail() ? static_cast<std::size_t>(_stream.gcount()) : _buffer.size();
148 }145 }
149 146
150 return _current_size - _current_index;147 return _current_size - _current_index;