Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/wolfpld/tracy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartosz Taudul <wolf.pld@gmail.com>2019-03-03 18:36:00 +0300
committerBartosz Taudul <wolf.pld@gmail.com>2019-03-03 20:05:03 +0300
commitcf8d17c2ec7fa60288b91e29fbf5de84e1504b29 (patch)
tree9b4c4f3fa12b6dfa0c03c045ad1ca37fde0957fb /server/TracyVarArray.hpp
parente3c31e4a4e8fa4cc2549335d088d491280eb6cec (diff)
Move VarArray hash calculation to a separate function.
Diffstat (limited to 'server/TracyVarArray.hpp')
-rw-r--r--server/TracyVarArray.hpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/server/TracyVarArray.hpp b/server/TracyVarArray.hpp
index d63a9772..45f6d2c9 100644
--- a/server/TracyVarArray.hpp
+++ b/server/TracyVarArray.hpp
@@ -21,12 +21,7 @@ public:
: m_size( size )
, m_ptr( data )
{
- T hash = 5381;
- for( uint8_t i=0; i<size; i++ )
- {
- hash = ( ( hash << 5 ) + hash ) ^ data[i];
- }
- m_hash = uint32_t( hash );
+ CalcHash();
}
VarArray( const VarArray& ) = delete;
@@ -51,6 +46,8 @@ public:
tracy_force_inline const T& operator[]( size_t idx ) const { return m_ptr[idx]; }
private:
+ tracy_force_inline void CalcHash();
+
uint8_t m_size;
uint32_t m_hash;
const T* m_ptr;
@@ -58,6 +55,17 @@ private:
#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>
bool Compare( const VarArray<T>& lhs, const VarArray<T>& rhs )
{
if( lhs.size() != rhs.size() || lhs.get_hash() != rhs.get_hash() ) return false;