From e7a6906da6a462ec1d830e3847eef6c9890f6843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Mon, 12 Dec 2011 13:37:51 +0100 Subject: [PATCH] Remove template class QRingBuffer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit .. as it is declared and defined in .cpp file but never used. Change-Id: I7b72daf62712b4ec25717afbe2b7f0792ffa2a85 Reviewed-by: Samuel Rødal --- src/gui/opengl/qtriangulator.cpp | 72 -------------------------------- 1 file changed, 72 deletions(-) diff --git a/src/gui/opengl/qtriangulator.cpp b/src/gui/opengl/qtriangulator.cpp index 67c2a6494e..ae7eb21e72 100644 --- a/src/gui/opengl/qtriangulator.cpp +++ b/src/gui/opengl/qtriangulator.cpp @@ -720,78 +720,6 @@ inline void QInt64Set::clear() m_count = 0; } -//============================================================================// -// QRingBuffer // -//============================================================================// - -// T must be POD. -template -class QRingBuffer -{ -public: - inline QRingBuffer() : m_array(0), m_head(0), m_size(0), m_capacity(0) { } - inline ~QRingBuffer() {if (m_array) delete[] m_array;} - bool reallocate(int capacity); - inline const T &head() const {Q_ASSERT(m_size > 0); return m_array[m_head];} - inline const T &dequeue(); - inline void enqueue(const T &x); - inline bool isEmpty() const {return m_size == 0;} -private: - T *m_array; - int m_head; - int m_size; - int m_capacity; -}; - -template -bool QRingBuffer::reallocate(int capacity) -{ - T *oldArray = m_array; - m_array = new T[capacity]; - if (m_array) { - if (oldArray) { - if (m_head + m_size > m_capacity) { - memcpy(m_array, oldArray + m_head, (m_capacity - m_head) * sizeof(T)); - memcpy(m_array + (m_capacity - m_head), oldArray, (m_head + m_size - m_capacity) * sizeof(T)); - } else { - memcpy(m_array, oldArray + m_head, m_size * sizeof(T)); - } - delete[] oldArray; - } - m_capacity = capacity; - m_head = 0; - return true; - } else { - m_array = oldArray; - return false; - } -} - -template -inline const T &QRingBuffer::dequeue() -{ - Q_ASSERT(m_size > 0); - Q_ASSERT(m_array); - Q_ASSERT(m_capacity >= m_size); - int index = m_head; - if (++m_head >= m_capacity) - m_head -= m_capacity; - --m_size; - return m_array[index]; -} - -template -inline void QRingBuffer::enqueue(const T &x) -{ - if (m_size == m_capacity) - reallocate(qMax(2 * m_capacity, 64)); - int index = m_head + m_size; - if (index >= m_capacity) - index -= m_capacity; - m_array[index] = x; - ++m_size; -} - //============================================================================// // QTriangulator // //============================================================================//