mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Implement resize() in tracy::Vector.
This commit is contained in:
parent
a8b41faaf4
commit
a96f58c3de
@ -115,6 +115,14 @@ public:
|
|||||||
return begin;
|
return begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reserve( size_t cap )
|
||||||
|
{
|
||||||
|
if( cap <= m_capacity ) return;
|
||||||
|
memUsage.fetch_add( ( cap - m_capacity ) * sizeof( T ), std::memory_order_relaxed );
|
||||||
|
m_capacity = cap;
|
||||||
|
Realloc();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void AllocMore()
|
void AllocMore()
|
||||||
{
|
{
|
||||||
@ -128,6 +136,11 @@ private:
|
|||||||
memUsage.fetch_add( m_capacity * sizeof( T ), std::memory_order_relaxed );
|
memUsage.fetch_add( m_capacity * sizeof( T ), std::memory_order_relaxed );
|
||||||
m_capacity *= 2;
|
m_capacity *= 2;
|
||||||
}
|
}
|
||||||
|
Realloc();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Realloc()
|
||||||
|
{
|
||||||
T* ptr = new T[m_capacity];
|
T* ptr = new T[m_capacity];
|
||||||
if( m_size != 0 )
|
if( m_size != 0 )
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user