Skip to content

Commit

Permalink
HPCC-32136 Minor modifications to streaming classes
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday committed Jun 25, 2024
1 parent 5946df1 commit 6835477
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions system/jlib/jstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ IByteInputStream *createInputStream(int handle)
// This means the buffer size is likely to be bigger than the block size - the class is passed
// an initial estimate for the potential overlap.

class CBlockedSerialInputStream : public CInterfaceOf<IBufferedSerialInputStream>
class CBlockedSerialInputStream final : public CInterfaceOf<IBufferedSerialInputStream>
{
public:
CBlockedSerialInputStream(ISerialInputStream * _input, size32_t _blockReadSize)
Expand Down Expand Up @@ -318,7 +318,7 @@ class CBlockedSerialInputStream : public CInterfaceOf<IBufferedSerialInputStream
}

//While there are blocks larger than the buffer size read directly into the target buffer
while (sizeRead + blockReadSize <= len)
while (unlikely(sizeRead + blockReadSize <= len))
{
size32_t got = readNextBlock(blockReadSize, target+sizeRead);
if ((got == 0) || (got == BufferTooSmall))
Expand All @@ -327,7 +327,7 @@ class CBlockedSerialInputStream : public CInterfaceOf<IBufferedSerialInputStream
nextBlockOffset += got;
}

while ((sizeRead < len) && !endOfStream)
while (likely((sizeRead < len) && !endOfStream))
{
assertex(bufferOffset == dataLength);
// NOTE: This could read less than a block, even if a whole block was requested.
Expand Down Expand Up @@ -368,7 +368,7 @@ class CBlockedSerialInputStream : public CInterfaceOf<IBufferedSerialInputStream
virtual void get(size32_t len, void * ptr) override
{
size32_t numRead = read(len, ptr);
if (numRead != len)
if (unlikely(numRead != len))
throw makeStringExceptionV(-1, "End of input stream for read of %u bytes at offset %llu", len, tell()-numRead);
}

Expand Down

0 comments on commit 6835477

Please sign in to comment.