mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Add magic field to Vector.
This commit is contained in:
parent
7be19193d9
commit
60c2b53d47
@ -22,7 +22,7 @@ namespace tracy
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
class Vector
|
class Vector
|
||||||
{
|
{
|
||||||
constexpr uint8_t MaxCapacity() { return std::numeric_limits<uint8_t>::max(); }
|
constexpr uint8_t MaxCapacity() { return 0x7F; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using iterator = T*;
|
using iterator = T*;
|
||||||
@ -32,6 +32,7 @@ public:
|
|||||||
: m_ptr( nullptr )
|
: m_ptr( nullptr )
|
||||||
, m_size( 0 )
|
, m_size( 0 )
|
||||||
, m_capacity( 0 )
|
, m_capacity( 0 )
|
||||||
|
, m_magic( 0 )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ public:
|
|||||||
: m_ptr( new T[1] )
|
: m_ptr( new T[1] )
|
||||||
, m_size( 1 )
|
, m_size( 1 )
|
||||||
, m_capacity( 0 )
|
, m_capacity( 0 )
|
||||||
|
, m_magic( 0 )
|
||||||
{
|
{
|
||||||
memUsage.fetch_add( sizeof( T ), std::memory_order_relaxed );
|
memUsage.fetch_add( sizeof( T ), std::memory_order_relaxed );
|
||||||
m_ptr[0] = value;
|
m_ptr[0] = value;
|
||||||
@ -264,6 +266,9 @@ public:
|
|||||||
m_size = 0;
|
m_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tracy_force_inline bool is_magic() const { return m_magic; }
|
||||||
|
tracy_force_inline void set_magic() { assert( !m_magic ); m_magic = 1; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
tracy_no_inline void AllocMore()
|
tracy_no_inline void AllocMore()
|
||||||
{
|
{
|
||||||
@ -320,7 +325,8 @@ private:
|
|||||||
short_ptr<T> m_ptr;
|
short_ptr<T> m_ptr;
|
||||||
#endif
|
#endif
|
||||||
uint32_t m_size;
|
uint32_t m_size;
|
||||||
uint8_t m_capacity;
|
uint8_t m_capacity : 7;
|
||||||
|
uint8_t m_magic : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user