mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 22:44:34 +00:00
Split read/write functions into small and big variants.
This commit is contained in:
parent
79418d0c57
commit
41d8ca0814
@ -29,11 +29,30 @@ public:
|
||||
tracy_force_inline void Read( void* ptr, size_t size )
|
||||
{
|
||||
if( size <= BufSize - m_offset )
|
||||
{
|
||||
ReadSmall( ptr, size );
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadBig( ptr, size );
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
FileRead( FILE* f )
|
||||
: m_stream( LZ4_createStreamDecode() )
|
||||
, m_file( f )
|
||||
, m_offset( BufSize )
|
||||
, m_active( 1 )
|
||||
{}
|
||||
|
||||
tracy_force_inline void ReadSmall( void* ptr, size_t size )
|
||||
{
|
||||
memcpy( ptr, m_buf[m_active] + m_offset, size );
|
||||
m_offset += size;
|
||||
}
|
||||
else
|
||||
|
||||
void ReadBig( void* ptr, size_t size )
|
||||
{
|
||||
auto dst = (char*)ptr;
|
||||
while( size > 0 )
|
||||
@ -55,15 +74,6 @@ public:
|
||||
size -= sz;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
FileRead( FILE* f )
|
||||
: m_stream( LZ4_createStreamDecode() )
|
||||
, m_file( f )
|
||||
, m_offset( BufSize )
|
||||
, m_active( 1 )
|
||||
{}
|
||||
|
||||
enum { BufSize = 64 * 1024 };
|
||||
enum { LZ4Size = LZ4_COMPRESSBOUND( BufSize ) };
|
||||
|
@ -33,11 +33,30 @@ public:
|
||||
tracy_force_inline void Write( const void* ptr, size_t size )
|
||||
{
|
||||
if( m_offset + size <= BufSize )
|
||||
{
|
||||
WriteSmall( ptr, size );
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteBig( ptr, size );
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
FileWrite( FILE* f )
|
||||
: m_stream( LZ4_createStream() )
|
||||
, m_file( f )
|
||||
, m_offset( 0 )
|
||||
, m_active( 0 )
|
||||
{}
|
||||
|
||||
tracy_force_inline void WriteSmall( const void* ptr, size_t size )
|
||||
{
|
||||
memcpy( m_buf[m_active] + m_offset, ptr, size );
|
||||
m_offset += size;
|
||||
}
|
||||
else
|
||||
|
||||
void WriteBig( const void* ptr, size_t size )
|
||||
{
|
||||
auto src = (const char*)ptr;
|
||||
while( size > 0 )
|
||||
@ -54,15 +73,6 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
FileWrite( FILE* f )
|
||||
: m_stream( LZ4_createStream() )
|
||||
, m_file( f )
|
||||
, m_offset( 0 )
|
||||
, m_active( 0 )
|
||||
{}
|
||||
|
||||
void WriteLz4Block()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user