From da2b59d083f7c5be24b8ec4506d55ad6637e67a2 Mon Sep 17 00:00:00 2001 From: Reece Date: Tue, 18 Jan 2022 16:56:54 +0000 Subject: [PATCH] [*] Add move constructor --- Include/Aurora/Memory/ByteBuffer.hpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Include/Aurora/Memory/ByteBuffer.hpp b/Include/Aurora/Memory/ByteBuffer.hpp index 4e955fb3..790fa879 100644 --- a/Include/Aurora/Memory/ByteBuffer.hpp +++ b/Include/Aurora/Memory/ByteBuffer.hpp @@ -72,6 +72,25 @@ namespace Aurora::Memory AuUInt8 scaleSize;// : 4; screw it.... we should just take 6 * (4/8) up to 32/64, we wont go up a slab allocation bucket, whatever you want to call it /////////////////////////////////////////////////////////////////////// + ByteBuffer(ByteBuffer &&buffer) + { + this->base = buffer.base; + this->length = buffer.length; + this->allocSize = buffer.length; + this->writePtr = this->base + (buffer.writePtr - buffer.base); + this->readPtr = this->base + (buffer.readPtr - buffer.base); + this->flagCircular = buffer.flagCircular; + this->flagExpandable = buffer.flagExpandable; + this->scaleSize = buffer.scaleSize; + buffer.base = {}; + buffer.length = {}; + buffer.allocSize = {}; + buffer.writePtr = {}; + buffer.readPtr = {}; + buffer.flagCircular = {}; + buffer.flagExpandable = {}; + buffer.scaleSize = {}; + } ByteBuffer(const ByteBuffer &buffer, bool preservePointers = true) { @@ -92,7 +111,7 @@ namespace Aurora::Memory std::memcpy(this->base, buffer.base, this->length); this->flagCircular = buffer.flagCircular; this->flagExpandable = buffer.flagExpandable; - this->scaleSize = kBufferInitialPower; + this->scaleSize = buffer.scaleSize; } ByteBuffer(const void *in, AuUInt length, bool circular = false, bool expandable = false) : flagCircular(circular), flagExpandable(expandable), flagReadError(0), flagWriteError(0)