From b598300186d6f8d99d19a6fb6ca443b7a681621a Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 30 Apr 2018 02:31:03 +0200 Subject: [PATCH] Split FileRead::Skip into small and big part. --- server/TracyFileRead.hpp | 41 ++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/server/TracyFileRead.hpp b/server/TracyFileRead.hpp index 6c9810c1..0ebcb5d6 100644 --- a/server/TracyFileRead.hpp +++ b/server/TracyFileRead.hpp @@ -42,7 +42,7 @@ public: } } - void Skip( size_t size ) + tracy_force_inline void Skip( size_t size ) { if( size <= BufSize - m_offset ) { @@ -50,23 +50,7 @@ public: } else { - char m_lz4buf[LZ4Size]; - while( size > 0 ) - { - if( m_offset == BufSize ) - { - std::swap( m_buf, m_second ); - m_offset = 0; - uint32_t sz; - fread( &sz, 1, sizeof( sz ), m_file ); - fread( m_lz4buf, 1, sz, m_file ); - m_lastBlock = LZ4_decompress_safe_continue( m_stream, m_lz4buf, m_buf, sz, BufSize ); - } - - const auto sz = std::min( size, BufSize - m_offset ); - m_offset += sz; - size -= sz; - } + SkipBig( size ); } } @@ -132,6 +116,27 @@ private: } } + void SkipBig( size_t size ) + { + char m_lz4buf[LZ4Size]; + while( size > 0 ) + { + if( m_offset == BufSize ) + { + std::swap( m_buf, m_second ); + m_offset = 0; + uint32_t sz; + fread( &sz, 1, sizeof( sz ), m_file ); + fread( m_lz4buf, 1, sz, m_file ); + m_lastBlock = LZ4_decompress_safe_continue( m_stream, m_lz4buf, m_buf, sz, BufSize ); + } + + const auto sz = std::min( size, BufSize - m_offset ); + m_offset += sz; + size -= sz; + } + } + enum { BufSize = 64 * 1024 }; enum { LZ4Size = LZ4_COMPRESSBOUND( BufSize ) };