From cd86f802035ef4678c4c7259fcf3a7175daf1642 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 22 Aug 2024 12:51:30 +0300 Subject: [PATCH] engine: common: make MSG_WriteOneBit inlined, as it's usually called with literal argument --- engine/common/net_buffer.c | 11 ----------- engine/common/net_buffer.h | 12 +++++++++++- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/engine/common/net_buffer.c b/engine/common/net_buffer.c index 6526c386..69580a39 100644 --- a/engine/common/net_buffer.c +++ b/engine/common/net_buffer.c @@ -160,17 +160,6 @@ void MSG_InitMasks( void ) ExtraMasks[maskBit] = (uint)BIT( maskBit ) - 1; } -void MSG_WriteOneBit( sizebuf_t *sb, int nValue ) -{ - if( !MSG_Overflow( sb, 1 )) - { - if( nValue ) sb->pData[sb->iCurBit>>3] |= BIT( sb->iCurBit & 7 ); - else sb->pData[sb->iCurBit>>3] &= ~BIT( sb->iCurBit & 7 ); - - sb->iCurBit++; - } -} - void MSG_WriteUBitLong( sizebuf_t *sb, uint curData, int numbits ) { Assert( numbits >= 0 && numbits <= 32 ); diff --git a/engine/common/net_buffer.h b/engine/common/net_buffer.h index 12282d78..e278f737 100644 --- a/engine/common/net_buffer.h +++ b/engine/common/net_buffer.h @@ -173,7 +173,17 @@ void MSG_InitMasks( void ); // called once at startup engine void MSG_ExciseBits( sizebuf_t *sb, int startbit, int bitstoremove ); // Bit-write functions -void MSG_WriteOneBit( sizebuf_t *sb, int nValue ); +static inline void MSG_WriteOneBit( sizebuf_t *sb, int nValue ) +{ + if( !MSG_Overflow( sb, 1 )) + { + if( nValue ) sb->pData[sb->iCurBit>>3] |= BIT( sb->iCurBit & 7 ); + else sb->pData[sb->iCurBit>>3] &= ~BIT( sb->iCurBit & 7 ); + + sb->iCurBit++; + } +} + NO_ASAN void MSG_WriteUBitLong( sizebuf_t *sb, uint curData, int numbits ); void MSG_WriteSBitLong( sizebuf_t *sb, int data, int numbits ); void MSG_WriteBitLong( sizebuf_t *sb, uint data, int numbits, qboolean bSigned );