diff options
author | ReinUsesLisp <[email protected]> | 2018-10-03 00:32:45 -0300 |
---|---|---|
committer | ReinUsesLisp <[email protected]> | 2018-10-03 00:32:45 -0300 |
commit | 0485e1877c33a1521716d32ca4e5a1193aec473f (patch) | |
tree | 4949774c8c514521328e6193c0d54349e2ecd4cb /src/stream.cpp | |
parent | 45555c0e570b24409e19c9cb0cbfb0866f897d3d (diff) | |
download | sirit-0485e1877c33a1521716d32ca4e5a1193aec473f.tar.gz sirit-0485e1877c33a1521716d32ca4e5a1193aec473f.zip |
Use some C++17 features
Diffstat (limited to 'src/stream.cpp')
-rw-r--r-- | src/stream.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/stream.cpp b/src/stream.cpp index a1144aa..8bfdf65 100644 --- a/src/stream.cpp +++ b/src/stream.cpp @@ -8,42 +8,39 @@ namespace Sirit { -Stream::Stream(std::vector<u8>& bytes_) - : bytes(bytes_) {} +Stream::Stream(std::vector<u8>& bytes_) : bytes(bytes_) {} Stream::~Stream() = default; void Stream::Write(std::string string) { - std::size_t size{string.size()}; - u8* data{reinterpret_cast<u8*>(string.data())}; - for (std::size_t i{}; i < size; i++) { + const auto size{string.size()}; + const auto data{reinterpret_cast<u8*>(string.data())}; + for (std::size_t i = 0; i < size; i++) { Write(data[i]); } - for (std::size_t i{}; i < 4 - size % 4; i++) { + for (std::size_t i = 0; i < 4 - size % 4; i++) { Write(static_cast<u8>(0)); } } void Stream::Write(u64 value) { - u32* mem{reinterpret_cast<u32*>(&value)}; + const auto mem{reinterpret_cast<u32*>(&value)}; Write(mem[0]); Write(mem[1]); } void Stream::Write(u32 value) { - u16* mem{reinterpret_cast<u16*>(&value)}; + const auto mem{reinterpret_cast<u16*>(&value)}; Write(mem[0]); Write(mem[1]); } void Stream::Write(u16 value) { - u8* mem{reinterpret_cast<u8*>(&value)}; + const auto mem{reinterpret_cast<u8*>(&value)}; Write(mem[0]); Write(mem[1]); } -void Stream::Write(u8 value) { - bytes.push_back(value); -} +void Stream::Write(u8 value) { bytes.push_back(value); } } // namespace Sirit |