1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-28 20:23:51 +00:00

Deduplicate code.

This commit is contained in:
Bartosz Taudul 2020-02-23 19:16:33 +01:00
parent adbde78a7a
commit 085e1fd43f

View File

@ -34,10 +34,7 @@ public:
tracy_force_inline void* AllocRaw( size_t size )
{
assert( size <= BlockSize );
if( m_offset + size > BlockSize )
{
DoAlloc();
}
if( m_offset + size > BlockSize ) DoAlloc();
void* ret = m_ptr + m_offset;
m_offset += size;
return ret;
@ -47,14 +44,8 @@ public:
tracy_force_inline T* AllocInit()
{
const auto size = sizeof( T );
assert( size <= BlockSize );
if( m_offset + size > BlockSize )
{
DoAlloc();
}
void* ret = m_ptr + m_offset;
auto ret = AllocRaw( size );
new( ret ) T;
m_offset += size;
return (T*)ret;
}
@ -62,19 +53,13 @@ public:
tracy_force_inline T* AllocInit( size_t sz )
{
const auto size = sizeof( T ) * sz;
assert( size <= BlockSize );
if( m_offset + size > BlockSize )
{
DoAlloc();
}
void* ret = m_ptr + m_offset;
auto ret = AllocRaw( size );
T* ptr = (T*)ret;
for( size_t i=0; i<sz; i++ )
{
new( ptr ) T;
ptr++;
}
m_offset += size;
return (T*)ret;
}