Add ToSpan for MemoryWriteStream and simplify code with it

This commit is contained in:
Wojtek Figat
2025-01-16 17:35:28 +01:00
parent 39419787fa
commit 6111f67e33
30 changed files with 59 additions and 51 deletions

View File

@@ -1,6 +1,7 @@
// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
#include "MemoryReadStream.h"
#include "Engine/Platform/Platform.h"
MemoryReadStream::MemoryReadStream()
: _buffer(nullptr)
@@ -22,6 +23,14 @@ void MemoryReadStream::Init(const byte* bytes, uint32 length)
_length = length;
}
void* MemoryReadStream::Move(uint32 bytes)
{
ASSERT(GetLength() - GetPosition() >= bytes);
const auto result = (void*)_position;
_position += bytes;
return result;
}
void MemoryReadStream::Flush()
{
}