Audacity 3.2.0
|
A low overhead memory stream with O(1) append, low heap fragmentation and a linear memory view. More...
#include <MemoryStream.h>
Classes | |
struct | Chunk |
struct | Iterator |
Public Types | |
using | StreamData = std::vector< uint8_t > |
using | StreamChunk = std::pair< const void *, size_t > |
Public Member Functions | |
MemoryStream ()=default | |
MemoryStream (MemoryStream &&)=default | |
void | Clear () |
void | AppendByte (char data) |
void | AppendData (const void *data, const size_t length) |
const void * | GetData () const |
const size_t | GetSize () const noexcept |
bool | IsEmpty () const noexcept |
Iterator | begin () const |
Iterator | end () const |
Private Types | |
using | ChunksList = std::list< Chunk > |
Private Attributes | |
ChunksList | mChunks |
StreamData | mLinearData |
size_t | mDataSize { 0 } |
Static Private Attributes | |
static constexpr size_t | ChunkSize |
A low overhead memory stream with O(1) append, low heap fragmentation and a linear memory view.
wxMemoryBuffer always appends 1Kb to the end of the buffer, causing severe performance issues and significant heap fragmentation. There is no possibility to control the increment value.
std::vector doubles its memory size which can be problematic for large projects as well. Not as bad as wxMemoryBuffer though.
Definition at line 30 of file lib-utility/memorystream.h.
|
private |
Definition at line 51 of file lib-utility/memorystream.h.
using MemoryStream::StreamChunk = std::pair<const void*, size_t> |
Definition at line 34 of file lib-utility/memorystream.h.
using MemoryStream::StreamData = std::vector<uint8_t> |
Definition at line 33 of file lib-utility/memorystream.h.
|
default |
|
default |
void MemoryStream::AppendByte | ( | char | data | ) |
Definition at line 22 of file lib-utility/memorystream.cpp.
References AppendData().
Referenced by ProjectSerializer::EndTag(), ProjectSerializer::ProjectSerializer(), ProjectSerializer::StartTag(), ProjectSerializer::Write(), ProjectSerializer::WriteAttr(), ProjectSerializer::WriteData(), XMLUtf8BufferWriter::WriteEscaped(), and ProjectSerializer::WriteName().
void MemoryStream::AppendData | ( | const void * | data, |
const size_t | length | ||
) |
Definition at line 27 of file lib-utility/memorystream.cpp.
References mChunks, and mDataSize.
Referenced by AppendByte(), ProjectSerializer::ProjectSerializer(), XMLUtf8BufferWriter::Write(), ProjectSerializer::Write(), ProjectSerializer::WriteAttr(), anonymous_namespace{ProjectSerializer.cpp}::WriteBigEndian(), ProjectSerializer::WriteData(), anonymous_namespace{ProjectSerializer.cpp}::WriteLittleEndian(), and ProjectSerializer::WriteName().
MemoryStream::Iterator MemoryStream::begin | ( | ) | const |
Definition at line 105 of file lib-utility/memorystream.cpp.
Referenced by GetData().
void MemoryStream::Clear | ( | ) |
Definition at line 15 of file lib-utility/memorystream.cpp.
References mChunks, mDataSize, and mLinearData.
MemoryStream::Iterator MemoryStream::end | ( | ) | const |
Definition at line 110 of file lib-utility/memorystream.cpp.
Referenced by GetData().
const void * MemoryStream::GetData | ( | ) | const |
Definition at line 40 of file lib-utility/memorystream.cpp.
References begin(), end(), GetSize(), mChunks, and mLinearData.
|
noexcept |
Definition at line 62 of file lib-utility/memorystream.cpp.
References mDataSize.
Referenced by GetData(), ProjectSerializer::IsEmpty(), audacity::cloud::audiocom::sync::ProjectCloudExtension::OnUpdateSaved(), and ProjectFileIO::WriteDoc().
|
noexcept |
Definition at line 100 of file lib-utility/memorystream.cpp.
References mDataSize.
|
staticconstexprprivate |
Definition at line 37 of file lib-utility/memorystream.h.
Referenced by MemoryStream::Chunk::Append().
|
mutableprivate |
Definition at line 99 of file lib-utility/memorystream.h.
Referenced by AppendData(), Clear(), and GetData().
|
private |
Definition at line 102 of file lib-utility/memorystream.h.
Referenced by AppendData(), Clear(), GetSize(), and IsEmpty().
|
mutableprivate |
Definition at line 100 of file lib-utility/memorystream.h.