diff options
author | Mike Buland <eichlan@xagasoft.com> | 2010-05-13 21:11:47 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2010-05-13 21:11:47 +0000 |
commit | 7ad392ce0426a040cc55713691bf6fdbf53c3d31 (patch) | |
tree | a50a7cb05f0d8550a7a37aa0cc3f3090250148e7 /src/queuebuf.cpp | |
parent | 093ef85e95d1b37e4a87ffc2a51433b2f1ed24e0 (diff) | |
download | libbu++-7ad392ce0426a040cc55713691bf6fdbf53c3d31.tar.gz libbu++-7ad392ce0426a040cc55713691bf6fdbf53c3d31.tar.bz2 libbu++-7ad392ce0426a040cc55713691bf6fdbf53c3d31.tar.xz libbu++-7ad392ce0426a040cc55713691bf6fdbf53c3d31.zip |
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.
Diffstat (limited to 'src/queuebuf.cpp')
-rw-r--r-- | src/queuebuf.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
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 ) | |||
76 | return nBytes - iLeft; | 76 | return nBytes - iLeft; |
77 | } | 77 | } |
78 | 78 | ||
79 | size_t Bu::QueueBuf::peek( void *pRawBuf, size_t nBytes ) | 79 | size_t Bu::QueueBuf::peek( void *pBuf, size_t nBytes ) |
80 | { | ||
81 | return peek( pBuf, nBytes, 0 ); | ||
82 | } | ||
83 | |||
84 | size_t Bu::QueueBuf::peek( void *pRawBuf, size_t nBytes, size_t nSkip ) | ||
80 | { | 85 | { |
81 | if( nBytes <= 0 ) | 86 | if( nBytes <= 0 ) |
82 | return 0; | 87 | return 0; |
@@ -87,12 +92,16 @@ size_t Bu::QueueBuf::peek( void *pRawBuf, size_t nBytes ) | |||
87 | size_t iLeft = nBytes; | 92 | size_t iLeft = nBytes; |
88 | char *pBuf = (char *)pRawBuf; | 93 | char *pBuf = (char *)pRawBuf; |
89 | 94 | ||
90 | int iTmpReadOffset = iReadOffset; | 95 | int iTmpReadOffset = iReadOffset + nSkip; |
91 | size_t iTmpRemSize = iTotalSize; | 96 | size_t iTmpRemSize = iTotalSize; |
92 | BlockList::iterator iBlock = lBlocks.begin(); | 97 | BlockList::iterator iBlock = lBlocks.begin(); |
98 | while( iTmpReadOffset > iBlockSize ) | ||
99 | { | ||
100 | iTmpReadOffset -= iBlockSize; | ||
101 | iBlock++; | ||
102 | } | ||
93 | while( iLeft > 0 && iTmpRemSize > 0 ) | 103 | while( iLeft > 0 && iTmpRemSize > 0 ) |
94 | { | 104 | { |
95 | // Switching to use temp variables instead of iReadOffset and iTotalSize | ||
96 | if( iTmpReadOffset == iBlockSize ) | 105 | if( iTmpReadOffset == iBlockSize ) |
97 | { | 106 | { |
98 | iBlock++; | 107 | iBlock++; |