[*] cache these adapter allocations away

This commit is contained in:
Reece Wilson 2023-04-26 07:37:14 +01:00
parent 30b0c2e0ba
commit 3f0368b99d
2 changed files with 15 additions and 2 deletions

View File

@ -402,7 +402,12 @@ namespace Aurora::IO::Protocol
return {};
}
return AuMakeShared<AuIO::Buffered::BlobWriter>(this->pSourceBufer);
if (this->pStreamWriterCache)
{
return this->pStreamWriterCache;
}
return this->pStreamWriterCache = AuMakeShared<AuIO::Buffered::BlobWriter>(this->pSourceBufer);
}
AuSPtr<Memory::ByteBuffer> ProtocolStack::AsWritableByteBuffer()
@ -423,7 +428,12 @@ namespace Aurora::IO::Protocol
return {};
}
return AuMakeShared<AuIO::Buffered::BlobReader>(pBuffer);
if (this->pStreamReaderCache)
{
return this->pStreamReaderCache;
}
return this->pStreamReaderCache = AuMakeShared<AuIO::Buffered::BlobReader>(pBuffer);
}
AuSPtr<Memory::ByteBuffer> ProtocolStack::AsReadableByteBuffer()

View File

@ -51,5 +51,8 @@ namespace Aurora::IO::Protocol
AuWPtr<AuIO::IOPipeWork> pPipeWork;
bool bKillPipeOnFirstRootLevelFalse {};
AuSPtr<IStreamReader> pStreamReaderCache;
AuSPtr<IStreamWriter> pStreamWriterCache;
};
}