Jamba C++ API 7.5.0
Loading...
Searching...
No Matches
FastWriteMemoryStream Class Reference

This class is a copy of MemoryStream for the purpose of fixing the growing issue encountered on Windows 10 when writing a lot of data to it. More...

#include <FastWriteMemoryStream.h>

Inherits IBStream.

Public Member Functions

void clear ()
 FastWriteMemoryStream ()
char const * getData () const
TSize getSize () const
int64 pos () const
virtual tresult PLUGIN_API read (void *buffer, int32 numBytes, int32 *numBytesRead) SMTG_OVERRIDE
void reset ()
virtual tresult PLUGIN_API seek (int64 pos, int32 mode, int64 *result) SMTG_OVERRIDE
void setSize (TSize size)
 returns the current memory size
virtual tresult PLUGIN_API tell (int64 *pos) SMTG_OVERRIDE
virtual tresult PLUGIN_API write (void *buffer, int32 numBytes, int32 *numBytesWritten) SMTG_OVERRIDE
virtual ~FastWriteMemoryStream ()

Protected Attributes

bool allocationError
int64 cursor
char * memory
TSize memorySize
TSize size

Detailed Description

This class is a copy of MemoryStream for the purpose of fixing the growing issue encountered on Windows 10 when writing a lot of data to it.

MemoryStream essentially adds 4k whenever new memory is needed and although realloc is being used, it is extremelly slow on PC/Windows 10. This class implements a similar strategy found in std::vector: the memory is doubled every time which leads to much less realloc and much faster performance.

This class does not implement the "non-owning" code since MemoryStream can be used for this (no memory allocation).

This class fixes the issue with MemoryStream::seek which blindly sets the cursor potentially outside the valid boundaries.

Constructor & Destructor Documentation

◆ FastWriteMemoryStream()

FastWriteMemoryStream ( )

◆ ~FastWriteMemoryStream()

~FastWriteMemoryStream ( )
virtual

Member Function Documentation

◆ clear()

void clear ( )
inline

◆ getData()

char const * getData ( ) const
inline

◆ getSize()

TSize getSize ( ) const
inline

◆ pos()

int64 pos ( ) const
inline

◆ read()

tresult PLUGIN_API read ( void * buffer,
int32 numBytes,
int32 * numBytesRead )
virtual

◆ reset()

void reset ( )

◆ seek()

tresult PLUGIN_API seek ( int64 pos,
int32 mode,
int64 * result )
virtual

◆ setSize()

void setSize ( TSize size)

returns the current memory size

set the memory size, a realloc will occur if memory already used

◆ tell()

tresult PLUGIN_API tell ( int64 * pos)
virtual

◆ write()

tresult PLUGIN_API write ( void * buffer,
int32 numBytes,
int32 * numBytesWritten )
virtual

Member Data Documentation

◆ allocationError

bool allocationError
protected

◆ cursor

int64 cursor
protected

◆ memory

char* memory
protected

◆ memorySize

TSize memorySize
protected

◆ size

TSize size
protected

The documentation for this class was generated from the following files: