From 7ad392ce0426a040cc55713691bf6fdbf53c3d31 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 13 May 2010 21:11:47 +0000 Subject: QueueBuf is updated, and everything else uses it now, including Client. Unfortunately this breaks some programs that accessed the client internal buffer directly. Overall it's much, much more efficient, so it's worth it, maybe we'll find a good workaround later. --- src/queuebuf.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/queuebuf.cpp') diff --git a/src/queuebuf.cpp b/src/queuebuf.cpp index 9577793..01d92f8 100644 --- a/src/queuebuf.cpp +++ b/src/queuebuf.cpp @@ -76,7 +76,12 @@ size_t Bu::QueueBuf::read( void *pRawBuf, size_t nBytes ) return nBytes - iLeft; } -size_t Bu::QueueBuf::peek( void *pRawBuf, size_t nBytes ) +size_t Bu::QueueBuf::peek( void *pBuf, size_t nBytes ) +{ + return peek( pBuf, nBytes, 0 ); +} + +size_t Bu::QueueBuf::peek( void *pRawBuf, size_t nBytes, size_t nSkip ) { if( nBytes <= 0 ) return 0; @@ -87,12 +92,16 @@ size_t Bu::QueueBuf::peek( void *pRawBuf, size_t nBytes ) size_t iLeft = nBytes; char *pBuf = (char *)pRawBuf; - int iTmpReadOffset = iReadOffset; + int iTmpReadOffset = iReadOffset + nSkip; size_t iTmpRemSize = iTotalSize; BlockList::iterator iBlock = lBlocks.begin(); + while( iTmpReadOffset > iBlockSize ) + { + iTmpReadOffset -= iBlockSize; + iBlock++; + } while( iLeft > 0 && iTmpRemSize > 0 ) { - // Switching to use temp variables instead of iReadOffset and iTotalSize if( iTmpReadOffset == iBlockSize ) { iBlock++; -- cgit v1.2.3