You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2021/02/27 13:17:40 UTC
svn commit: r1886983 -
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessReadBuffer.java
Author: lehmi
Date: Sat Feb 27 13:17:40 2021
New Revision: 1886983
URL: http://svn.apache.org/viewvc?rev=1886983&view=rev
Log:
PDFBOX-5111: simplify implementation
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessReadBuffer.java
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessReadBuffer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessReadBuffer.java?rev=1886983&r1=1886982&r2=1886983&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessReadBuffer.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/RandomAccessReadBuffer.java Sat Feb 27 13:17:40 2021
@@ -105,28 +105,21 @@ public class RandomAccessReadBuffer impl
int remainingBytes = chunkSize;
int offset = 0;
byte[] eofCheck = new byte[1];
- while (true)
+ while ((bytesRead = input.read(currentBuffer.array(), offset, remainingBytes)) > -1)
{
- while (remainingBytes > 0
- && (bytesRead = input.read(currentBuffer.array(), offset, remainingBytes)) > -1)
- {
- remainingBytes -= bytesRead;
- offset += bytesRead;
- }
- size += offset;
+ remainingBytes -= bytesRead;
+ offset += bytesRead;
+ size += bytesRead;
if (remainingBytes == 0 && input.read(eofCheck) > 0)
{
expandBuffer();
currentBuffer.put(eofCheck);
offset = 1;
remainingBytes = chunkSize - 1;
- }
- else
- {
- currentBuffer.limit(offset);
- break;
+ size++;
}
}
+ currentBuffer.limit(offset);
seek(0);
}