From 5deeb8426f2f9cb78c34e72e30e06fcb564743cc Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 1 May 2018 01:47:29 +0200 Subject: [PATCH] Specialized Read function writing directly to registers. --- server/TracyFileRead.hpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/server/TracyFileRead.hpp b/server/TracyFileRead.hpp index 0ebcb5d6..d566bc41 100644 --- a/server/TracyFileRead.hpp +++ b/server/TracyFileRead.hpp @@ -54,6 +54,41 @@ public: } } + template + tracy_force_inline void Read( T& v ) + { + if( sizeof( T ) < BufSize - m_offset ) + { + memcpy( &v, m_buf + m_offset, sizeof( T ) ); + m_offset += sizeof( T ); + } + else + { + T tmp; + ReadBig( &tmp, sizeof( T ) ); + memcpy( &v, &tmp, sizeof( T ) ); + } + + } + + template + tracy_force_inline void Read2( T& v0, T& v1 ) + { + if( sizeof( T ) * 2 < BufSize - m_offset ) + { + memcpy( &v0, m_buf + m_offset, sizeof( T ) ); + memcpy( &v1, m_buf + m_offset + sizeof( T ), sizeof( T ) ); + m_offset += sizeof( T ) * 2; + } + else + { + T tmp[2]; + ReadBig( tmp, sizeof( T ) * 2 ); + memcpy( &v0, tmp, sizeof( T ) ); + memcpy( &v1, tmp+1, sizeof( T ) ); + } + } + bool IsEOF() { if( m_lastBlock != BufSize && m_offset == m_lastBlock ) return true;