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 2015/12/24 15:08:21 UTC
svn commit: r1721623 -
/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/DataInput.java
Author: lehmi
Date: Thu Dec 24 14:08:20 2015
New Revision: 1721623
URL: http://svn.apache.org/viewvc?rev=1721623&view=rev
Log:
PDFBOX-3131: use the buffer and System.arraycopy instead of reading one byte after the other, simplify readByte
Modified:
pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/DataInput.java
Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/DataInput.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/DataInput.java?rev=1721623&r1=1721622&r2=1721623&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/DataInput.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/DataInput.java Thu Dec 24 14:08:20 2015
@@ -85,7 +85,16 @@ public class DataInput
*/
public byte readByte() throws IOException
{
- return (byte) readUnsignedByte();
+ try
+ {
+ byte value = inputBuffer[bufferPosition];
+ bufferPosition++;
+ return value;
+ }
+ catch (RuntimeException re)
+ {
+ return -1;
+ }
}
/**
@@ -170,11 +179,13 @@ public class DataInput
*/
public byte[] readBytes(int length) throws IOException
{
- byte[] bytes = new byte[length];
- for (int i = 0; i < length; i++)
+ if (inputBuffer.length - bufferPosition < length)
{
- bytes[i] = readByte();
+ throw new EOFException();
}
+ byte[] bytes = new byte[length];
+ System.arraycopy(inputBuffer, bufferPosition, bytes, 0, length);
+ bufferPosition += length;
return bytes;
}