ArrayAppendCache< T > Class Template Reference

#include <streamconversion_impl_helper.h>

Detailed Description

template<typename T>
class maxon::ArrayAppendCache< T >

Helper to Append efficiently to WritableArrayInterface<> by caching several append calls and writing them back in blocks Without this caching mechanism calling Append directly can slow down by a factor of 4 or even more! Usage:

FastArrayAppend<UChar> dst(xdst); // xdst is the WritableArrayInterface of type UChar
for (auto ch : src)
{
iferr (dst.Append(ch))
return err;
}
iferr (dst.Finalize()) // tell the FastArrayAppend that we are finished and remaning elements in the cache should be copied as well
return err;
Py_UCS4 ch
Definition: unicodeobject.h:676
const ARG & src
Definition: apibase.h:2633
#define iferr(...)
Definition: errorbase.h:388

Public Member Functions

MAXON_IMPLICIT ArrayAppendCache (WritableArrayInterface< Generic > &destination)
 
 ArrayAppendCache ()
 
MAXON_ATTRIBUTE_FORCE_INLINE Result< void > Append (const T &ch)
 
MAXON_ATTRIBUTE_FORCE_INLINE Result< void > Finalize ()
 
Int GetCount () const
 

Private Attributes

Int _tempPos
 
_tempArray [DEFAULT_APPENDSIZE]
 
WritableArrayInterface< T > * _destination
 

Constructor & Destructor Documentation

◆ ArrayAppendCache() [1/2]

◆ ArrayAppendCache() [2/2]

Member Function Documentation

◆ Append()

MAXON_ATTRIBUTE_FORCE_INLINE Result<void> Append ( const T &  ch)

◆ Finalize()

◆ GetCount()

Int GetCount ( void  ) const

Member Data Documentation

◆ _tempPos

Int _tempPos
private

◆ _tempArray

T _tempArray[DEFAULT_APPENDSIZE]
private

◆ _destination

WritableArrayInterface<T>* _destination
private