mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-19 13:03:11 +01:00
Add compile time selection for copying data with specialised paths (#9331)
This commit is contained in:
committed by
Michael Steenbeek
parent
f4a1b75a53
commit
f6a23fd5f5
@@ -155,10 +155,35 @@ void MemoryStream::Read(void* buffer, uint64_t length)
|
||||
throw IOException("Attempted to read past end of stream.");
|
||||
}
|
||||
|
||||
std::copy_n((const uint8_t*)_position, length, (uint8_t*)buffer);
|
||||
std::memcpy(buffer, _position, length);
|
||||
_position = (void*)((uintptr_t)_position + length);
|
||||
}
|
||||
|
||||
void MemoryStream::Read1(void* buffer)
|
||||
{
|
||||
Read<1>(buffer);
|
||||
}
|
||||
|
||||
void MemoryStream::Read2(void* buffer)
|
||||
{
|
||||
Read<2>(buffer);
|
||||
}
|
||||
|
||||
void MemoryStream::Read4(void* buffer)
|
||||
{
|
||||
Read<4>(buffer);
|
||||
}
|
||||
|
||||
void MemoryStream::Read8(void* buffer)
|
||||
{
|
||||
Read<8>(buffer);
|
||||
}
|
||||
|
||||
void MemoryStream::Read16(void* buffer)
|
||||
{
|
||||
Read<16>(buffer);
|
||||
}
|
||||
|
||||
uint64_t MemoryStream::TryRead(void* buffer, uint64_t length)
|
||||
{
|
||||
uint64_t remainingBytes = GetLength() - GetPosition();
|
||||
@@ -183,11 +208,36 @@ void MemoryStream::Write(const void* buffer, uint64_t length)
|
||||
}
|
||||
}
|
||||
|
||||
std::copy_n((const uint8_t*)buffer, length, (uint8_t*)_position);
|
||||
std::memcpy(_position, buffer, length);
|
||||
_position = (void*)((uintptr_t)_position + length);
|
||||
_dataSize = std::max<size_t>(_dataSize, (size_t)nextPosition);
|
||||
}
|
||||
|
||||
void MemoryStream::Write1(const void* buffer)
|
||||
{
|
||||
Write<1>(buffer);
|
||||
}
|
||||
|
||||
void MemoryStream::Write2(const void* buffer)
|
||||
{
|
||||
Write<2>(buffer);
|
||||
}
|
||||
|
||||
void MemoryStream::Write4(const void* buffer)
|
||||
{
|
||||
Write<4>(buffer);
|
||||
}
|
||||
|
||||
void MemoryStream::Write8(const void* buffer)
|
||||
{
|
||||
Write<8>(buffer);
|
||||
}
|
||||
|
||||
void MemoryStream::Write16(const void* buffer)
|
||||
{
|
||||
Write<16>(buffer);
|
||||
}
|
||||
|
||||
void MemoryStream::EnsureCapacity(size_t capacity)
|
||||
{
|
||||
if (_dataCapacity < capacity)
|
||||
|
||||
Reference in New Issue
Block a user