mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 12:23:53 +00:00
Move VarArray hash calculation to a separate function.
This commit is contained in:
parent
e3c31e4a4e
commit
cf8d17c2ec
@ -21,12 +21,7 @@ public:
|
|||||||
: m_size( size )
|
: m_size( size )
|
||||||
, m_ptr( data )
|
, m_ptr( data )
|
||||||
{
|
{
|
||||||
T hash = 5381;
|
CalcHash();
|
||||||
for( uint8_t i=0; i<size; i++ )
|
|
||||||
{
|
|
||||||
hash = ( ( hash << 5 ) + hash ) ^ data[i];
|
|
||||||
}
|
|
||||||
m_hash = uint32_t( hash );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VarArray( const VarArray& ) = delete;
|
VarArray( const VarArray& ) = delete;
|
||||||
@ -51,12 +46,25 @@ public:
|
|||||||
tracy_force_inline const T& operator[]( size_t idx ) const { return m_ptr[idx]; }
|
tracy_force_inline const T& operator[]( size_t idx ) const { return m_ptr[idx]; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
tracy_force_inline void CalcHash();
|
||||||
|
|
||||||
uint8_t m_size;
|
uint8_t m_size;
|
||||||
uint32_t m_hash;
|
uint32_t m_hash;
|
||||||
const T* m_ptr;
|
const T* m_ptr;
|
||||||
};
|
};
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void VarArray<T>::CalcHash()
|
||||||
|
{
|
||||||
|
T hash = 5381;
|
||||||
|
for( uint8_t i=0; i<m_size; i++ )
|
||||||
|
{
|
||||||
|
hash = ( ( hash << 5 ) + hash ) ^ m_ptr[i];
|
||||||
|
}
|
||||||
|
m_hash = uint32_t( hash );
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool Compare( const VarArray<T>& lhs, const VarArray<T>& rhs )
|
bool Compare( const VarArray<T>& lhs, const VarArray<T>& rhs )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user