Skip to content

Commit 56a8532

Browse files
Merge pull request #10 from valverl/bitreader_layout
Unified memory layout of BitReader across debug and release builds
2 parents 13bccb4 + 44673d5 commit 56a8532

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

serialize.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ namespace serialize
589589
{
590590
m_data = NULL;
591591
m_numBytes = 0;
592+
m_numWords = 0;
592593
m_numBits = m_numBytes * 8;
593594
m_bitsRead = 0;
594595
m_scratch = 0;
@@ -620,11 +621,7 @@ namespace serialize
620621
@see BitWriter
621622
*/
622623

623-
#ifdef SERIALIZE_DEBUG
624624
BitReader( const void * serialize_restrict data, int bytes ) : m_data( (const uint32_t*) data ), m_numBytes( bytes ), m_numWords( ( bytes + 3 ) / 4 )
625-
#else // #ifdef SERIALIZE_DEBUG
626-
BitReader( const void * serialize_restrict data, int bytes ) : m_data( (const uint32_t*) data ), m_numBytes( bytes )
627-
#endif // #ifdef SERIALIZE_DEBUG
628625
{
629626
serialize_assert( data );
630627
m_numBits = m_numBytes * 8;
@@ -788,9 +785,7 @@ namespace serialize
788785
uint64_t m_scratch; ///< The scratch value. New data is read in 32 bits at a top to the left of this buffer, and data is read off to the right.
789786
int m_numBits; ///< Number of bits to read in the buffer. Of course, we can't *really* know this so it's actually m_numBytes * 8.
790787
int m_numBytes; ///< Number of bytes to read in the buffer. We know this, and this is the non-rounded up version.
791-
#ifdef SERIALIZE_DEBUG
792-
int m_numWords; ///< Number of words to read in the buffer. This is rounded up to the next word if necessary.
793-
#endif // #ifdef SERIALIZE_DEBUG
788+
int m_numWords; ///< Number of words to read in the buffer. This is rounded up to the next word if necessary. Only used in debug builds.
794789
int m_bitsRead; ///< Number of bits read from the buffer so far.
795790
int m_scratchBits; ///< Number of bits currently in the scratch value. If the user wants to read more bits than this, we have to go fetch another dword from memory.
796791
int m_wordIndex; ///< Index of the next word to read from memory.

0 commit comments

Comments
 (0)