From bc3098ab792cdaad2a633ba03d00323be9d1e240 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Tue, 24 Dec 2013 09:59:27 +0000 Subject: [PATCH] use std copy function instead of a while loop --- src/buffer.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/buffer.h b/src/buffer.h index 234f6770..891a8ff2 100755 --- a/src/buffer.h +++ b/src/buffer.h @@ -446,29 +446,27 @@ public: bool Put ( const CVector& vecsData ) { + // calculate the input size and the end position after copying const int iVecSize = vecsData.Size(); - - // copy new data in internal buffer - int iCurPos = 0; - const int iEnd = iPutPos + iVecSize; + const int iEnd = iPutPos + iVecSize; // first check for buffer overrun if ( iEnd <= iMemSize ) { - // actual copy operation - while ( iPutPos < iEnd ) - { - vecsMemory[iPutPos++] = vecsData[iCurPos++]; - } + // copy new data in internal buffer + std::copy ( vecsData.begin(), + vecsData.begin() + iVecSize, + vecsMemory.begin() + iPutPos ); + + // set buffer pointer one block further + iPutPos = iEnd; // return "buffer is ready for readout" flag return ( iEnd == iMemSize ); } - else - { - // buffer overrun or not initialized, return "not ready" - return false; - } + + // buffer overrun or not initialized, return "not ready" + return false; } CVector Get()