You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Sergey Vladimirov (JIRA)" <ji...@apache.org> on 2011/04/27 12:50:03 UTC
[jira] [Created] (PDFBOX-1006) Unnecessary using intermediate
ByteArrayInputStream to copy from given byte array to OutputStream in
FlateFilter::decode
Unnecessary using intermediate ByteArrayInputStream to copy from given byte array to OutputStream in FlateFilter::decode
------------------------------------------------------------------------------------------------------------------------
Key: PDFBOX-1006
URL: https://issues.apache.org/jira/browse/PDFBOX-1006
Project: PDFBox
Issue Type: Improvement
Affects Versions: 1.5.0
Reporter: Sergey Vladimirov
Priority: Trivial
It is not required to use intermediate ByteArrayInputStream to copy from given byte array to OutputStream. When we have byte[], it's okay just to call write(byte[]) method of OutputStream to write all data at once.
AS IS:
// Copy data to ByteArrayInputStream for reading
bais = new ByteArrayInputStream(baos.toByteArray());
baos.close();
baos = null;
byte[] decodedData = decodePredictor(predictor, colors, bitsPerPixel, columns, bais);
bais.close();
bais = new ByteArrayInputStream(decodedData);
// write decoded data to result
while ((amountRead = bais.read(buffer)) != -1)
{
result.write(buffer, 0, amountRead);
}
bais.close();
bais = null;
TO BE:
// Copy data to ByteArrayInputStream for reading
bais = new ByteArrayInputStream(baos.toByteArray());
baos.close();
baos = null;
byte[] decodedData = decodePredictor(predictor, colors, bitsPerPixel, columns, bais);
bais.close();
bais = null;
result.write(decodedData);
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Resolved] (PDFBOX-1006) Unnecessary using intermediate
ByteArrayInputStream to copy from given byte array to OutputStream in
FlateFilter::decode
Posted by "Andreas Lehmkühler (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-1006?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andreas Lehmkühler resolved PDFBOX-1006.
----------------------------------------
Resolution: Fixed
Fix Version/s: 1.6.0
Assignee: Andreas Lehmkühler
I added the improvement in revision 1133726 as proposed.
Thanks for the contribution!
> Unnecessary using intermediate ByteArrayInputStream to copy from given byte array to OutputStream in FlateFilter::decode
> ------------------------------------------------------------------------------------------------------------------------
>
> Key: PDFBOX-1006
> URL: https://issues.apache.org/jira/browse/PDFBOX-1006
> Project: PDFBox
> Issue Type: Improvement
> Affects Versions: 1.5.0
> Reporter: Sergey Vladimirov
> Assignee: Andreas Lehmkühler
> Priority: Trivial
> Fix For: 1.6.0
>
> Attachments: FlateFilter.java.patch
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> It is not required to use intermediate ByteArrayInputStream to copy from given byte array to OutputStream. When we have byte[], it's okay just to call write(byte[]) method of OutputStream to write all data at once.
> AS IS:
> // Copy data to ByteArrayInputStream for reading
> bais = new ByteArrayInputStream(baos.toByteArray());
> baos.close();
> baos = null;
> byte[] decodedData = decodePredictor(predictor, colors, bitsPerPixel, columns, bais);
> bais.close();
> bais = new ByteArrayInputStream(decodedData);
> // write decoded data to result
> while ((amountRead = bais.read(buffer)) != -1)
> {
> result.write(buffer, 0, amountRead);
> }
> bais.close();
> bais = null;
> TO BE:
> // Copy data to ByteArrayInputStream for reading
> bais = new ByteArrayInputStream(baos.toByteArray());
> baos.close();
> baos = null;
> byte[] decodedData = decodePredictor(predictor, colors, bitsPerPixel, columns, bais);
> bais.close();
> bais = null;
> result.write(decodedData);
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (PDFBOX-1006) Unnecessary using intermediate
ByteArrayInputStream to copy from given byte array to OutputStream in
FlateFilter::decode
Posted by "Sergey Vladimirov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-1006?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sergey Vladimirov updated PDFBOX-1006:
--------------------------------------
Attachment: FlateFilter.java.patch
patch
> Unnecessary using intermediate ByteArrayInputStream to copy from given byte array to OutputStream in FlateFilter::decode
> ------------------------------------------------------------------------------------------------------------------------
>
> Key: PDFBOX-1006
> URL: https://issues.apache.org/jira/browse/PDFBOX-1006
> Project: PDFBox
> Issue Type: Improvement
> Affects Versions: 1.5.0
> Reporter: Sergey Vladimirov
> Priority: Trivial
> Attachments: FlateFilter.java.patch
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> It is not required to use intermediate ByteArrayInputStream to copy from given byte array to OutputStream. When we have byte[], it's okay just to call write(byte[]) method of OutputStream to write all data at once.
> AS IS:
> // Copy data to ByteArrayInputStream for reading
> bais = new ByteArrayInputStream(baos.toByteArray());
> baos.close();
> baos = null;
> byte[] decodedData = decodePredictor(predictor, colors, bitsPerPixel, columns, bais);
> bais.close();
> bais = new ByteArrayInputStream(decodedData);
> // write decoded data to result
> while ((amountRead = bais.read(buffer)) != -1)
> {
> result.write(buffer, 0, amountRead);
> }
> bais.close();
> bais = null;
> TO BE:
> // Copy data to ByteArrayInputStream for reading
> bais = new ByteArrayInputStream(baos.toByteArray());
> baos.close();
> baos = null;
> byte[] decodedData = decodePredictor(predictor, colors, bitsPerPixel, columns, bais);
> bais.close();
> bais = null;
> result.write(decodedData);
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira