Access the pointer directly on isoBufferBuffer::insert (#71)

This commit is contained in:
Sebastián Mestre 2019-03-09 19:13:46 -03:00 committed by Chris Esposito
parent 681ef5cb13
commit eeb0db0318
1 changed files with 4 additions and 2 deletions

View File

@ -31,10 +31,12 @@ isoBufferBuffer::isoBufferBuffer(uint32_t length)
// Adds a character to the end of the buffer // Adds a character to the end of the buffer
void isoBufferBuffer::insert(char c) void isoBufferBuffer::insert(char c)
{ {
char* dataPtr = m_data.get();
// Add character to first half of the buffer // Add character to first half of the buffer
m_data[m_top] = c; dataPtr[m_top] = c;
// Then to the second // Then to the second
m_data[m_top+m_capacity] = c; dataPtr[m_top+m_capacity] = c;
// Loop the buffer index if necessary and update size accordingly // Loop the buffer index if necessary and update size accordingly
m_top = (m_top + 1) % m_capacity; m_top = (m_top + 1) % m_capacity;