From 71f4bf25a763f1edc92c2ef7b21a687da1ae0afa Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Thu, 4 Apr 2013 19:34:50 -0500 Subject: [PATCH] Make FifoQueue take advantage of rvalue references to avoid std::vector copies. --- Source/Core/Common/Src/FifoQueue.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/Core/Common/Src/FifoQueue.h b/Source/Core/Common/Src/FifoQueue.h index 2060ceee92..01f0e4dd3c 100644 --- a/Source/Core/Common/Src/FifoQueue.h +++ b/Source/Core/Common/Src/FifoQueue.h @@ -36,15 +36,16 @@ public: return (0 == m_size); } - const T& Front() const + T& Front() const { return *m_read_ptr->current; } - void Push(const T& t) + template + void Push(Arg&& t) { // create the element, add it to the queue - m_write_ptr->current = new T(t); + m_write_ptr->current = new T(std::forward(t)); // set the next pointer to a new element ptr // then advance the write pointer m_write_ptr = m_write_ptr->next = new ElementPtr(); @@ -67,7 +68,7 @@ public: if (Empty()) return false; - t = Front(); + t = std::move(Front()); Pop(); return true;