stevedlawrence closed pull request #66: Fix performance regression in layering
feature
URL: https://github.com/apache/incubator-daffodil/pull/66
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
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 7ded5ffac..c1e01e9df 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()
diff --git
a/daffodil-runtime1/src/main/scala/org/apache/daffodil/layers/LineFoldedTransformer.scala
b/daffodil-runtime1/src/main/scala/org/apache/daffodil/layers/LineFoldedTransformer.scala
index 7b659ec4b..48d388b4e 100644
---
a/daffodil-runtime1/src/main/scala/org/apache/daffodil/layers/LineFoldedTransformer.scala
+++
b/daffodil-runtime1/src/main/scala/org/apache/daffodil/layers/LineFoldedTransformer.scala
@@ -254,6 +254,7 @@ class LineFoldedInputStream(mode: LineFoldMode, jis:
InputStream)
*/
override def read(): Int = {
import State._
+ if (state eq Done) return -1
while (state != Done) {
state match {
case Start => {
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services