optimize Buffer::WriteU8
This commit is contained in:
@@ -668,35 +668,6 @@ Buffer::Iterator::WriteU8 (uint8_t data, uint32_t len)
|
||||
}
|
||||
}
|
||||
void
|
||||
Buffer::Iterator::WriteU8 (uint8_t data)
|
||||
{
|
||||
if (m_current < m_dataStart)
|
||||
{
|
||||
// XXX trying to write outside of data area
|
||||
NS_ASSERT (false);
|
||||
}
|
||||
else if (m_current < m_zeroStart)
|
||||
{
|
||||
m_data[m_current] = data;
|
||||
m_current++;
|
||||
}
|
||||
else if (m_current < m_zeroEnd)
|
||||
{
|
||||
// XXX trying to write in zero area
|
||||
NS_ASSERT (false);
|
||||
}
|
||||
else if (m_current < m_dataEnd)
|
||||
{
|
||||
m_data[m_current - (m_zeroEnd-m_zeroStart)] = data;
|
||||
m_current++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// XXX trying to write outside of data area
|
||||
NS_ASSERT (false);
|
||||
}
|
||||
}
|
||||
void
|
||||
Buffer::Iterator::WriteU16 (uint16_t data)
|
||||
{
|
||||
WriteU8 (data & 0xff);
|
||||
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
* Write the data in buffer and avance the iterator position
|
||||
* by one byte.
|
||||
*/
|
||||
void WriteU8 (uint8_t data);
|
||||
inline void WriteU8 (uint8_t data);
|
||||
/**
|
||||
* \param data data to write in buffer
|
||||
* \param len number of times data must be written in buffer
|
||||
@@ -346,6 +346,32 @@ private:
|
||||
uint32_t m_end;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#include "ns3/assert.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
void
|
||||
Buffer::Iterator::WriteU8 (uint8_t data)
|
||||
{
|
||||
NS_ASSERT (m_current >= m_dataStart &&
|
||||
!(m_current >= m_zeroStart && m_current <= m_zeroEnd) &&
|
||||
m_current <= m_dataEnd);
|
||||
|
||||
if (m_current < m_zeroStart)
|
||||
{
|
||||
m_data[m_current] = data;
|
||||
m_current++;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_data[m_current - (m_zeroEnd-m_zeroStart)] = data;
|
||||
m_current++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* BUFFER_H */
|
||||
|
||||
Reference in New Issue
Block a user