From f348fc4fbc2d6094b24b42b27a10c9ecbda3643f Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Wed, 6 Jun 2007 13:56:42 +0200 Subject: [PATCH] remove useless CanAdd --- src/common/packet-history.cc | 36 ++++-------------------------------- src/common/packet-history.h | 2 -- 2 files changed, 4 insertions(+), 34 deletions(-) diff --git a/src/common/packet-history.cc b/src/common/packet-history.cc index 21ca8a1f0..a95c59013 100644 --- a/src/common/packet-history.cc +++ b/src/common/packet-history.cc @@ -569,34 +569,6 @@ PacketHistory::TryToAppend (uint32_t value, uint8_t **pBuffer, uint8_t *end) return false; } -bool -PacketHistory::IsFF16 (uint16_t index) const -{ - return m_data->m_data[index] == 0xff && m_data->m_data[index+1] == 0xff; -} - -bool -PacketHistory::CanAdd (bool atStart) const -{ - if (m_head == 0xffff) - { - NS_ASSERT (m_tail == 0xffff); - return true; - } - if (atStart) - { - return IsFF16 (m_head+2); - } - else if (!atStart) - { - return IsFF16 (m_tail); - } - else - { - return false; - } -} - void PacketHistory::Update (bool atStart, uint16_t written) { @@ -646,8 +618,8 @@ PacketHistory::AddSmall (bool atStart, uint8_t *start = &m_data->m_data[m_used]; uint8_t *end = &m_data->m_data[m_data->m_size]; if (end - start >= 7 && - CanAdd (atStart) && - (m_data->m_count == 1 || + (m_head == 0xffff || + m_data->m_count == 1 || m_used == m_data->m_dirtyEnd)) { uint8_t *buffer = start; @@ -703,8 +675,8 @@ PacketHistory::AddBig (bool atStart, uint8_t *start = &m_data->m_data[m_used]; uint8_t *end = &m_data->m_data[m_data->m_size]; if (end - start >= 10 && - CanAdd (atStart) && - (m_data->m_count == 1 || + (m_head == 0xffff || + m_data->m_count == 1 || m_used == m_data->m_dirtyEnd)) { uint8_t *buffer = start; diff --git a/src/common/packet-history.h b/src/common/packet-history.h index e5a99bc1e..ada462a29 100644 --- a/src/common/packet-history.h +++ b/src/common/packet-history.h @@ -112,8 +112,6 @@ private: inline void Append16 (uint16_t value, uint8_t *buffer); inline bool TryToAppend (uint32_t value, uint8_t **pBuffer, uint8_t *end); inline bool TryToAppendFast (uint32_t value, uint8_t **pBuffer, uint8_t *end); - inline bool IsFF16 (uint16_t index) const; - inline bool CanAdd (bool atStart) const; void ReadSmall (struct PacketHistory::SmallItem *item, const uint8_t **pBuffer) const; void ReadExtra (struct PacketHistory::ExtraItem *item, const uint8_t **pBuffer) const; void Reserve (uint32_t n);