You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by sl...@apache.org on 2018/05/04 18:44:58 UTC
[incubator-daffodil] 01/02: Fix performance regression in layering
feature
This is an automated email from the ASF dual-hosted git repository.
slawrence pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-daffodil.git
commit f2b9088eb74f98217ee9f3d7af9f379ccfe9ea25
Author: Steve Lawrence <sl...@apache.org>
AuthorDate: Fri May 4 10:10:45 2018 -0400
Fix performance regression in layering feature
Commit 1ea2290f28 changed how the input data was copied to a
ByteArrayOutputStream by coping byte-by-byte rather than use
IOUtils.copy(). The byte-by-byte change was useful for debugging, but
caused a noticeable performance hit since IOUtils.copy() can copy in
chunks. Revert the change to bring back the performance.
DAFFODIL-1933
---
.../scala/org/apache/daffodil/io/ByteBufferDataInputStream.scala | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/daffodil-io/src/main/scala/org/apache/daffodil/io/ByteBufferDataInputStream.scala b/daffodil-io/src/main/scala/org/apache/daffodil/io/ByteBufferDataInputStream.scala
index 7ded5ff..c1e01e9 100644
--- a/daffodil-io/src/main/scala/org/apache/daffodil/io/ByteBufferDataInputStream.scala
+++ b/daffodil-io/src/main/scala/org/apache/daffodil/io/ByteBufferDataInputStream.scala
@@ -23,6 +23,7 @@ import org.apache.daffodil.schema.annotation.props.gen.UTF16Width
import org.apache.daffodil.schema.annotation.props.gen.BitOrder
import org.apache.daffodil.schema.annotation.props.gen.ByteOrder
import java.nio.charset.CodingErrorAction
+import org.apache.commons.io.IOUtils
import java.io.ByteArrayOutputStream
import java.nio.ByteBuffer
import org.apache.daffodil.exceptions.Assert
@@ -90,13 +91,7 @@ object ByteBufferDataInputStream {
case _ => {
// copy the contents of the stream into an array of bytes
val bos = new ByteArrayOutputStream
- var b: Int = 0
- while ({
- b = in.read()
- b != -1
- }) {
- bos.write(b)
- }
+ IOUtils.copy(in, bos)
bos.flush()
bos.close()
in.close()
--
To stop receiving notification emails like this one, please contact
slawrence@apache.org.