From 3d414de23eadccdf85fd1455a0dfcbce10e07cdd Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Tue, 28 Sep 2021 21:57:23 +0200 Subject: Removed MemoryOutStream, MemoryInStream BinaryWriter/BinaryReader now implements memory buffer functionality which previously needed two chained instances of a Buffer/Reader. This was originally expected to be an abstraction for file and other stream access but this is not going to be useful so may as well collapse the functionality. This also eliminates the need for stack-aware ref-counting which is the real reason for wanting to get rid of this code. This was a very old experimental feature which turned out to be a bad idea. This also removes the /cas/batch endpoint --- zencore/stream.cpp | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) (limited to 'zencore/stream.cpp') diff --git a/zencore/stream.cpp b/zencore/stream.cpp index b9a88de66..aa9705764 100644 --- a/zencore/stream.cpp +++ b/zencore/stream.cpp @@ -10,41 +10,19 @@ namespace zen { -MemoryInStream::MemoryInStream(const void* buffer, size_t size) -: m_Buffer(reinterpret_cast(buffer), reinterpret_cast(buffer) + size) -{ -} - void -MemoryInStream::Read(void* buffer, size_t byteCount, uint64_t offset) +BinaryWriter::Write(const void* data, size_t ByteCount, uint64_t Offset) { RwLock::ExclusiveLockScope _(m_Lock); - const size_t needEnd = offset + byteCount; - - if (needEnd > m_Buffer.size()) - throw std::runtime_error("read past end of file!"); // TODO: better exception + const size_t NeedEnd = Offset + ByteCount; - memcpy(buffer, m_Buffer.data() + offset, byteCount); -} + if (NeedEnd > m_Buffer.size()) + { + m_Buffer.resize(NeedEnd); + } -void -MemoryOutStream::Write(const void* data, size_t byteCount, uint64_t offset) -{ - RwLock::ExclusiveLockScope _(m_Lock); - - const size_t needEnd = offset + byteCount; - - if (needEnd > m_Buffer.size()) - m_Buffer.resize(needEnd); - - memcpy(m_Buffer.data() + offset, data, byteCount); -} - -void -MemoryOutStream::Flush() -{ - // No-op + memcpy(m_Buffer.data() + Offset, data, ByteCount); } ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3